zac commited on
Commit
3402c51
·
1 Parent(s): 884d32c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -8
app.py CHANGED
@@ -8,14 +8,18 @@ from huggingface_hub import hf_hub_download #load from huggingfaces
8
 
9
  llm = Llama(model_path= hf_hub_download(repo_id="TheBloke/airoboros-l2-13b-gpt4-m2.0-GGML", filename="airoboros-l2-13b-gpt4-m2.0.ggmlv3.q6_K.bin"), n_ctx=2048) #download model from hf/ n_ctx=2048 for high ccontext length
10
 
11
- description = " Bro i dont want learn! i just want results(https://github.com/abetlen/llama-cpp-python)"
12
- def generate_text(input_text):
13
- output = llm(f"Q: {input_text} \n A:", max_tokens=1024, stop=["Q:", "\n"], echo=True,)
14
- return output['choices'][0]['text']
15
 
 
 
 
 
 
 
 
 
 
16
 
17
- input_text = gr.inputs.Textbox(lines= 10, label="Enter your input text")
18
- output_text = gr.outputs.Textbox(label="Output text")
19
 
20
- demo = gr.Interface(fn=generate_text, inputs=input_text, outputs=output_text, title="Running Llama on CPU is Hard", description=description)
21
- demo.launch()
 
8
 
9
  llm = Llama(model_path= hf_hub_download(repo_id="TheBloke/airoboros-l2-13b-gpt4-m2.0-GGML", filename="airoboros-l2-13b-gpt4-m2.0.ggmlv3.q6_K.bin"), n_ctx=2048) #download model from hf/ n_ctx=2048 for high ccontext length
10
 
11
+ history = []
12
+ history.append(["Hi there!", "Hello, how can I help you?"])
 
 
13
 
14
+ def generate_text(input_text, history):
15
+ conversation_context = " ".join([f"{pair[0]} {pair[1]}" for pair in history])
16
+ full_conversation = f"{conversation_context} Q: {input_text} \n A:"
17
+
18
+ output = llm(full_conversation, max_tokens=1024, stop=["Q:", "\n"], echo=True)
19
+ response = output['choices'][0]['text']
20
+ history.append([input_text, response])
21
+
22
+ return response
23
 
24
+ gr.ChatInterface(generate_text).launch()
 
25