AFischer1985 commited on
Commit
ccc3e1a
·
1 Parent(s): 0a9f00a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -19
app.py CHANGED
@@ -8,27 +8,21 @@ response = requests.get(url)
8
  with open("./model.gguf", mode="wb") as file:
9
  file.write(response.content)
10
 
11
- app = create_app(
12
- Settings(
13
- n_threads=2, # set to number of cpu cores
14
- model="./model.gguf",
15
- embedding=False
16
- )
17
- )
18
 
19
- # Read the content of index.html once and store it in memory
20
- with open("index.html", "r") as f:
21
- content = f.read()
22
 
 
23
 
24
- @app.get("/", response_class=HTMLResponse)
25
- async def read_items():
26
- return content
 
 
27
 
28
- if __name__ == "__main__":
29
- import uvicorn
30
- uvicorn.run(app,
31
- host="0.0.0.0",
32
- port=int("2600")
33
- )
34
 
 
8
  with open("./model.gguf", mode="wb") as file:
9
  file.write(response.content)
10
 
11
+ llm = Llama(model_path="./model.gguf")
12
+ def generate_text(input_text):
13
+ output = llm(f"Q: {input_text} A:", max_tokens=256, stop=["Q:", "\n"], echo=True)
14
+ return output['choices'][0]['text']
 
 
 
15
 
16
+ input_text = gr.inputs.Textbox(lines= 10, label="Enter your input text")
17
+ output_text = gr.outputs.Textbox(label="Output text")
 
18
 
19
+ description = "llama.cpp implementation in python [https://github.com/abetlen/llama-cpp-python]"
20
 
21
+ examples = [
22
+ ["What is the capital of France? ", "The capital of France is Paris."],
23
+ ["Who wrote the novel 'Pride and Prejudice'?", "The novel 'Pride and Prejudice' was written by Jane Austen."],
24
+ ["What is the square root of 64?", "The square root of 64 is 8."]
25
+ ]
26
 
27
+ gr.Interface(fn=generate_text, inputs=input_text, outputs=output_text, title="Llama Language Model", description=description, examples=examples).launch()
 
 
 
 
 
28