TRaw commited on
Commit
f7a82b4
·
1 Parent(s): 5163024

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -24
app.py CHANGED
@@ -1,30 +1,19 @@
1
  import os
2
  import gradio as gr
3
- from langchain.chat_models import ChatLiteLLM
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['PALM_API_KEY'] = "AIzaSyBcSZ82EePKjrgZphWXMpKP3u3Kcfz_8AU" # Replace with your key
13
 
14
- chat = ChatLiteLLM(model="palm/chat-bison")
 
 
 
 
 
 
15
 
16
- def predict(message, history):
17
- history_langchain_format = []
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
- try:
24
- gpt_response = chat(history_langchain_format)
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()