as-cle-bert commited on
Commit
b151dc5
·
verified ·
1 Parent(s): 454f3c5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -11,7 +11,7 @@ load_dotenv()
11
  searcher = NeuralSearcher("pokemon_texts", "pokemon_images", qdrant_client, encoder, image_encoder, processor, sparse_encoder)
12
  semantic_cache = SemanticCache(qdrant_client, encoder, "semantic_cache", 0.75)
13
 
14
- def chat_pokemon(message: str):
15
  answer = semantic_cache.search_cache(message)
16
  if answer != "":
17
  r = ""
@@ -41,13 +41,13 @@ def card_package(n_cards:int=5):
41
  description, cards = choose_random_cards(n_cards)
42
  package = [f"![Card {i+1}]({cards[i]})" for i in range(len(cards))]
43
  cards_message = "\n\n".join(package)
44
- natural_lang_description = chat_completion([{"role": "system", "content": "You are an expert in Pokemon cards. You know everything about their characteristics, abilities, and evolutions. You always reply with the most accurate information, you are polite and helpful."}, {"role": "user", "content": f"Can you enthusiastically describe the cards in this package?\n\n{description}"}])
45
  return "## Your package:\n\n" + cards_message + "\n\n## Description:\n\n" + summarize(natural_lang_description)
46
 
47
 
48
  iface1 = gr.ChatInterface(fn=chat_pokemon, title="Pokemon Chatbot", description="Ask any question about Pokemon and get an answer!")
49
  iface2 = gr.Interface(fn=what_pokemon, title="Pokemon Image Classifier", description="Upload an image of a Pokemon and get its name!", inputs="image", outputs="text")
50
- iface3 = gr.Interface(fn=card_package, title="Pokemon Card Package", description="Get a package of random Pokemon cards!", inputs=gr.Slider(5,10,step=1), outputs=gr.Markdown(value="Your output will be displayed here", label="Card Package"))
51
 
52
  iface = gr.TabbedInterface([iface1, iface2, iface3], ["PokemonChat", "Identify Pokemon", "Card Package"])
53
 
 
11
  searcher = NeuralSearcher("pokemon_texts", "pokemon_images", qdrant_client, encoder, image_encoder, processor, sparse_encoder)
12
  semantic_cache = SemanticCache(qdrant_client, encoder, "semantic_cache", 0.75)
13
 
14
+ def chat_pokemon(message: str, history):
15
  answer = semantic_cache.search_cache(message)
16
  if answer != "":
17
  r = ""
 
41
  description, cards = choose_random_cards(n_cards)
42
  package = [f"![Card {i+1}]({cards[i]})" for i in range(len(cards))]
43
  cards_message = "\n\n".join(package)
44
+ natural_lang_description = chat_completion(f"Can you enthusiastically describe the cards in this package?\n\n{description}")
45
  return "## Your package:\n\n" + cards_message + "\n\n## Description:\n\n" + summarize(natural_lang_description)
46
 
47
 
48
  iface1 = gr.ChatInterface(fn=chat_pokemon, title="Pokemon Chatbot", description="Ask any question about Pokemon and get an answer!")
49
  iface2 = gr.Interface(fn=what_pokemon, title="Pokemon Image Classifier", description="Upload an image of a Pokemon and get its name!", inputs="image", outputs="text")
50
+ iface3 = gr.Interface(fn=card_package, title="Pokemon Card Package", description="Get a package of random Pokemon cards!", inputs=gr.Slider(5,10,step=1, label="Number of cards"), outputs=gr.Markdown(value="Your output will be displayed here", label="Card Package"))
51
 
52
  iface = gr.TabbedInterface([iface1, iface2, iface3], ["PokemonChat", "Identify Pokemon", "Card Package"])
53