TRaw commited on
Commit
535a20d
·
1 Parent(s): c9a70fe

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ from langchain.chat_models.fireworks import ChatFireworks
4
+ from langchain.schema import HumanMessage, SystemMessage, AIMessage
5
+ from langchain.memory import ConversationBufferMemory
6
+
7
+ os.environ["FIREWORKS_API_KEY"] = "ku9UYtzjSAATlcAstO8yrB89MzvDqJL3lGIkNgnVZ7URxPxK"
8
+
9
+ llm = ChatFireworks(
10
+ model="accounts/fireworks/models/llama-v2-13b-chat",
11
+ model_kwargs={"temperature": 0.2, "max_tokens": 64, "top_p": 1.0},
12
+ )
13
+
14
+ def predict(message, history):
15
+ history_langchain_format = []
16
+ for human, ai in history:
17
+ history_langchain_format.append(HumanMessage(content=human))
18
+ history_langchain_format.append(AIMessage(content=ai))
19
+ history_langchain_format.append(HumanMessage(content=message))
20
+ gpt_response = llm(history_langchain_format)
21
+ return gpt_response.content
22
+
23
+ gr.ChatInterface(predict).launch()