PabloVD commited on
Commit
7661979
·
1 Parent(s): 329cf37

First commit

Browse files
Files changed (2) hide show
  1. app.py +28 -0
  2. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from langchain_huggingface import HuggingFaceEndpoint
3
+
4
+ # Global variables
5
+ conversation_retrieval_chain = None
6
+
7
+ # load the model into the HuggingFaceHub
8
+ model_id = "microsoft/Phi-3.5-mini-instruct"
9
+ llm_hub = HuggingFaceEndpoint(repo_id=model_id, temperature=0.1, max_new_tokens=600, model_kwargs={"max_length":600})
10
+ # llm_hub.client.api_url = 'https://api-inference.huggingface.co/models/'+model_id
11
+
12
+ def handle_prompt(prompt, chat_history):
13
+
14
+ # Query the model
15
+ output = llm_hub.invoke({"question": prompt, "chat_history": chat_history})
16
+ answer = output["result"]
17
+
18
+ # Update the chat history
19
+ chat_history.append((prompt, answer))
20
+
21
+ # Return the model's response
22
+ return answer
23
+
24
+ greetingsmessage = "Hi, I'm a Chatbot!"
25
+
26
+ demo = gr.ChatInterface(handle_prompt, type="messages", title="ChatBot", theme='freddyaboulton/dracula_revamped', description=greetingsmessage)
27
+
28
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ langchain
2
+ langchain-community
3
+ langchain-huggingface
4
+ chromadb