Spaces:
Runtime error
Runtime error
trying some stuff
Browse files
app.py
CHANGED
|
@@ -7,11 +7,25 @@ from huggingface_hub import hf_hub_download #load from huggingfaces
|
|
| 7 |
|
| 8 |
|
| 9 |
llm = Llama(model_path= hf_hub_download(repo_id="TheBloke/Vigogne-2-7B-Instruct-GGML", filename="vigogne-2-7b-instruct.ggmlv3.q4_1.bin"), n_ctx=2048) #download model from hf/ n_ctx=2048 for high ccontext length
|
|
|
|
| 10 |
|
|
|
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
input_text = gr.inputs.Textbox(lines= 10, label="Enter your input text")
|
| 17 |
output_text = gr.outputs.Textbox(label="Output text")
|
|
@@ -24,7 +38,7 @@ examples = [
|
|
| 24 |
["What is the square root of 64?", "The square root of 64 is 8."]
|
| 25 |
]
|
| 26 |
|
| 27 |
-
demo = gr.
|
| 28 |
demo.queue()
|
| 29 |
demo.launch()
|
| 30 |
|
|
|
|
| 7 |
|
| 8 |
|
| 9 |
llm = Llama(model_path= hf_hub_download(repo_id="TheBloke/Vigogne-2-7B-Instruct-GGML", filename="vigogne-2-7b-instruct.ggmlv3.q4_1.bin"), n_ctx=2048) #download model from hf/ n_ctx=2048 for high ccontext length
|
| 10 |
+
chat_history = []
|
| 11 |
|
| 12 |
+
def generate_text(message,history):
|
| 13 |
|
| 14 |
+
if len(history) > 0:
|
| 15 |
+
user_input, bot_response = history[-1] # Get the latest pair from history
|
| 16 |
+
chat_history.append([user_input, message])
|
| 17 |
+
else:
|
| 18 |
+
chat_history.append([message, ""]) # If history is empty, just add the user input
|
| 19 |
+
|
| 20 |
+
input_text = message
|
| 21 |
+
output = llm(f"Q: {input_text} \n A:", max_tokens=521, stop=["Q:", "\n"], echo=True)
|
| 22 |
+
response = output['choices'][0]['text']
|
| 23 |
+
|
| 24 |
+
# Append the bot response to the chat history
|
| 25 |
+
chat_history[-1][1] = response
|
| 26 |
+
|
| 27 |
+
return response
|
| 28 |
+
|
| 29 |
|
| 30 |
input_text = gr.inputs.Textbox(lines= 10, label="Enter your input text")
|
| 31 |
output_text = gr.outputs.Textbox(label="Output text")
|
|
|
|
| 38 |
["What is the square root of 64?", "The square root of 64 is 8."]
|
| 39 |
]
|
| 40 |
|
| 41 |
+
demo = gr.ChatInterface(random_response).launch()
|
| 42 |
demo.queue()
|
| 43 |
demo.launch()
|
| 44 |
|