Update app.py
Browse files
app.py
CHANGED
@@ -1,30 +1,19 @@
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
-
from langchain.
|
4 |
-
from langchain.prompts.chat import (
|
5 |
-
ChatPromptTemplate,
|
6 |
-
SystemMessagePromptTemplate,
|
7 |
-
AIMessagePromptTemplate,
|
8 |
-
HumanMessagePromptTemplate,
|
9 |
-
)
|
10 |
-
from langchain.schema import AIMessage, HumanMessage, SystemMessage
|
11 |
|
12 |
-
os.environ[
|
13 |
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
for human, ai in history:
|
19 |
-
history_langchain_format.append(HumanMessage(content=human))
|
20 |
-
history_langchain_format.append(AIMessage(content=ai))
|
21 |
-
history_langchain_format.append(HumanMessage(content=message))
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
return gpt_response.content
|
26 |
-
except Exception as e:
|
27 |
-
print(f"An error occurred: {e}")
|
28 |
-
return "Sorry, I couldn't process that message."
|
29 |
-
|
30 |
-
gr.ChatInterface(predict).launch()
|
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
+
from langchain.llms import Together
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
+
os.environ["TOGETHERAI_API_KEY"] = "f722a9f6e3afd6b9999e6aee02aeac9e751ea3a67b124c3667ab50c85c7fa99e" # Replace with your key
|
6 |
|
7 |
+
llm = Together(
|
8 |
+
model="mistralai/Mistral-7B-v0.1",
|
9 |
+
temperature=0.7,
|
10 |
+
max_tokens=128,
|
11 |
+
top_k=1,
|
12 |
+
# together_api_key=""
|
13 |
+
)
|
14 |
|
15 |
+
input_ = """You are a teacher with a deep knowledge of machine learning and AI. \
|
16 |
+
You provide succinct and accurate answers. Answer the following question:
|
|
|
|
|
|
|
|
|
17 |
|
18 |
+
What is a large language model?"""
|
19 |
+
gr.ChatInterface(llm(input_)).launch()
|
|
|
|
|
|
|
|
|
|
|
|