Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add multi-turn conversation support with a gen() method #1002

Open
anrgct opened this issue Jan 13, 2025 · 7 comments
Open

add multi-turn conversation support with a gen() method #1002

anrgct opened this issue Jan 13, 2025 · 7 comments

Comments

@anrgct
Copy link

anrgct commented Jan 13, 2025

I found an interesting library appl that is somewhat similar to genaiscript. I think there is a method called gen() that is great for conducting multi-turn conversations within a script. Can it be added to genai? For example, using it like this.

$`gen 3 topics of joke.`
let topics = await gen();
let jokes = []
for(let topic of topics){
  $`gen a joke about ${topic}`
  jokes.push(await gen())
}
def("jokes", jokes)

$`which one is the best joke?`

gen() can execute multi-turn conversations within a script without the need for inline prompts.

@pelikhan
Copy link
Member

pelikhan commented Jan 13, 2025

I think you can acheive the sample with prompt:

const gen = prompt
const topics = await gen`gen 3 topics of joke.`.split(/\n/)
const jokes = []
for(let topic of topics){
  const joke = await gen`gen a joke about ${topic}`
  jokes.push(joke)
}
def("jokes", jokes)
$`which one is the best joke?`

@pelikhan
Copy link
Member

(prompt is argulally not the best name; maybe it should have been gen)

@anrgct
Copy link
Author

anrgct commented Jan 13, 2025

Oh, I mean the gen method can execute the entire script's request, generating multi-turn continuous dialogue.

@pelikhan
Copy link
Member

So in your example, you expect the entire set messages created by gen to be sent again to the LLM?

Copy link

add multi-turn conversation support with 'gen' method

AI-generated content by issue-reviewer may be incorrect

@anrgct
Copy link
Author

anrgct commented Jan 14, 2025

Yes, I hope it is an accumulative dialogue record, which is very suitable for multi-step, interrelated conversations and can conveniently control the direction of the dialogue.
The script above has turned into a dialogue like this.

user: gen 3 topics of joke.
assistant: ["Tech Support Humor","Programming Puns","Office/Work Comedy"]
user: gen a joke about Tech Support Humor
assistant: A programmer's wife tells him, "Go to the store and buy one loaf of bread. If they have eggs, get 10." He comes back with 10 loaves of bread.  
user: gen a joke about Programming Puns
assistant: Why do programmers prefer dark mode? Because light attracts bugs!  
user: gen a joke about Office/Work Comedy
assistant: A software engineer walks into a bar and orders 1.999999 drinks. The bartender says, "Sorry, we don't serve floating point numbers here."
user: ['A programmer's...', 'Why do programmers prefer...', 'A software engineer walks...'], which one is the best joke?
assistance: From the three jokes, the Programming Pun "Why do programmers prefer dark mode? Because light attracts bugs!" is arguably the best.

@pelikhan
Copy link
Member

This is a head banger; maybe it's doable with async iterators.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants