ahuang11 commited on
Commit
ab13803
1 Parent(s): 3119995

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -2
app.py CHANGED
@@ -1,3 +1,36 @@
1
- from tastymap import TastyKitchen
 
 
 
 
 
 
2
 
3
- TastyKitchen().servable()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from os import environ
2
+ from utils.ai import (
3
+ retrieve_context,
4
+ construct_prompt,
5
+ get_remote_chat_response,
6
+ )
7
+ import panel as pn
8
 
9
+ pn.extension()
10
+
11
+ MODEL = "gpt-3.5-turbo"
12
+ query = "How do I trigger a function when clicking a button in Panel?"
13
+
14
+
15
+ def seek(contents, user, instance):
16
+ messages = instance.serialize()[1:-1]
17
+ rag_context = retrieve_context(query, k=1, openai_api_key=environ["OPENAI_API_KEY"])
18
+ prompts = construct_prompt(
19
+ messages,
20
+ rag_context,
21
+ model=MODEL,
22
+ cite_sources=True,
23
+ context_window=4097,
24
+ )
25
+
26
+ message = None
27
+ for response in get_remote_chat_response(prompts, model=MODEL):
28
+ if response:
29
+ message = instance.stream(response, user="Fleet", message=message)
30
+
31
+
32
+ chat_interface = pn.chat.ChatInterface(callback=seek, callback_exception="verbose")
33
+ chat_interface.send("Ask me anything about Python libraries!", user="Fleet", respond=False)
34
+
35
+ template = pn.template.FastListTemplate(main=[chat_interface], title="Panel UI of Fleet Context")
36
+ template.servable()