Spaces:
Runtime error
Runtime error
Rockramsri
commited on
Commit
•
51af928
1
Parent(s):
2c502cc
update
Browse files
app.py
CHANGED
@@ -1,33 +1,39 @@
|
|
1 |
from fastapi import FastAPI
|
2 |
from llama_cpp import Llama
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
## create a new FASTAPI app instance
|
5 |
-
app=FastAPI()
|
6 |
|
7 |
# Initialize the text generation pipeline
|
8 |
#pipe = pipeline("text2text-generation", model="lmstudio-community/Meta-Llama-3.1-8B-Instruct-GGUF",token=os.getenv('HF_KEY'))
|
9 |
-
llm = Llama(
|
10 |
-
model_path="Meta-Llama-3.1-8B-Instruct-Q4_K_M.gguf",
|
11 |
-
)
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
32 |
|
33 |
|
|
|
1 |
from fastapi import FastAPI
|
2 |
from llama_cpp import Llama
|
3 |
+
import streamlit as st
|
4 |
+
|
5 |
+
llm = Llama(
|
6 |
+
model_path="Meta-Llama-3.1-8B-Instruct-Q4_K_M.gguf",
|
7 |
+
)
|
8 |
+
prompt = st.chat_input("Say something")
|
9 |
+
if prompt:
|
10 |
+
st.write(f"User has sent the following prompt: {prompt}")
|
11 |
|
12 |
## create a new FASTAPI app instance
|
13 |
+
# app=FastAPI()
|
14 |
|
15 |
# Initialize the text generation pipeline
|
16 |
#pipe = pipeline("text2text-generation", model="lmstudio-community/Meta-Llama-3.1-8B-Instruct-GGUF",token=os.getenv('HF_KEY'))
|
|
|
|
|
|
|
17 |
|
18 |
+
|
19 |
+
# @app.get("/")
|
20 |
+
# def home():
|
21 |
+
# print("helloe here")
|
22 |
+
# output= llm("What is the difference btw RAG and Fine tunning", max_tokens=1000)
|
23 |
+
# print(output["choices"][0]["text"])
|
24 |
+
# ## return the generate text in Json reposne
|
25 |
+
# return {"output":output["choices"][0]["text"]}
|
26 |
+
|
27 |
+
# # Define a function to handle the GET request at `/generate`
|
28 |
+
|
29 |
+
|
30 |
+
# @app.get("/generate")
|
31 |
+
# def generate(text:str):
|
32 |
+
# ## use the pipeline to generate text from given input text
|
33 |
+
# print("Recieved prompt "+str(text))
|
34 |
+
# output= llm(text, max_tokens=1000)
|
35 |
+
# print(output["choices"][0]["text"])
|
36 |
+
# ## return the generate text in Json reposne
|
37 |
+
# return {"output":output["choices"][0]["text"]}
|
38 |
|
39 |
|