Rockramsri commited on
Commit
51af928
1 Parent(s): 2c502cc
Files changed (1) hide show
  1. app.py +29 -23
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
- @app.get("/")
14
- def home():
15
- print("helloe here")
16
- output= llm("What is the difference btw RAG and Fine tunning", max_tokens=1000)
17
- print(output["choices"][0]["text"])
18
- ## return the generate text in Json reposne
19
- return {"output":output["choices"][0]["text"]}
20
-
21
- # Define a function to handle the GET request at `/generate`
22
-
23
-
24
- @app.get("/generate")
25
- def generate(text:str):
26
- ## use the pipeline to generate text from given input text
27
- print("Recieved prompt "+str(text))
28
- output= llm(text, max_tokens=1000)
29
- print(output["choices"][0]["text"])
30
- ## return the generate text in Json reposne
31
- return {"output":output["choices"][0]["text"]}
 
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