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

Bug fixed in conversation #710

Merged
merged 2 commits into from
Apr 2, 2024
Merged

Bug fixed in conversation #710

merged 2 commits into from
Apr 2, 2024

Conversation

javipacheco
Copy link
Contributor

@javipacheco javipacheco commented Apr 2, 2024

I found some problems running the Animal.kt example in Xef

The intention of Animal.kt is to demonstrate how Conversations work in Xef, and how it adds previous messages between the user and the assistant in the conversation.

This example execute 4 calls to OpenAi using ChatCompletions.

  1. Create a unique animal species
  2. Create a groundbreaking invention
  3. Create a story using the previous animal and invention
  4. Create another story using the animal and Cadiz city

The most important thing is you don't need to add the previous messages. With these changes I have executed the example locally with the next result:

Animal:

Animal(name=Axolotl, habitat=Freshwater, diet=Carnivorous)

Invention:

Invention(name=Internet, inventor=Tim Berners-Lee, year=1989, purpose=To connect computers and facilitate the sharing of information)

Story 1

In the depths of a secret laboratory, Dr. Amelia Collins was engrossed in her groundbreaking experiment. She had combined the unique DNA of an Axolotl, a rare amphibian species, with the power of the Internet, the invention that had revolutionized the world.

.....

Story 2:

In the bustling city of Cadiz, amidst the towering skyscrapers and honking cars, a peculiar creature roamed the streets. The Axolotl, with its vibrant fringed gills and curious eyes, became an enigmatic symbol of nature's resilience in an urban jungle. As people hurried past, the Axolotl observed their chaotic lives with a serene grace. Its presence reminded them of the beauty beyond concrete walls. Word spread, and soon, Cadiz became known for its harmonious coexistence of humans and this unique animal species. The city's heart transformed, embracing nature's marvels, and the Axolotl became a cherished emblem of Cadiz's extraordinary spirit.

For example, in Story 1 we are calling to Xef using:

val storyPrompt =
  Prompt(model) {
     +system("You are a writer for a science fiction magazine.")
     +user("Write a short story of 200 words that involves the animal and the invention")
}
val story: String = openAI.chat.promptMessage(storyPrompt, scope = this@Conversation)

Although we are not adding the Axolotl animal in the prompt, we can see this animal in the Story 1

I am going to add some comments in this PR to explain each problem I have encountered

raulraja
raulraja previously approved these changes Apr 2, 2024
@javipacheco javipacheco marked this pull request as ready for review April 2, 2024 14:25
nomisRev
nomisRev previously approved these changes Apr 2, 2024
Copy link
Contributor

@nomisRev nomisRev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me @javipacheco! 🙌

@javipacheco javipacheco dismissed stale reviews from nomisRev, Montagon, and raulraja via 4799494 April 2, 2024 14:36
@javipacheco javipacheco merged commit efa2181 into main Apr 2, 2024
6 checks passed
@javipacheco javipacheco deleted the fix-conversations branch April 2, 2024 14:46
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

Successfully merging this pull request may close these issues.

None yet

4 participants