Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,6 +7,7 @@ from custom_llm import CustomLLM
|
|
7 |
from pydantic import BaseModel
|
8 |
from langchain.prompts import PromptTemplate
|
9 |
from langchain_huggingface import HuggingFacePipeline
|
|
|
10 |
|
11 |
|
12 |
class ConversationPost(BaseModel):
|
@@ -16,19 +17,30 @@ class ConversationPost(BaseModel):
|
|
16 |
|
17 |
|
18 |
API_TOKEN = os.environ['HF_API_KEY']
|
|
|
|
|
|
|
19 |
app = FastAPI()
|
20 |
prompt = PromptTemplate.from_template("""<|im_start|>system
|
21 |
-
Kamu adalah Asisten AI yang dikembangkan oleh Jonthan Jordan.
|
22 |
<|im_start|>user
|
23 |
{question}<|im_end|>
|
24 |
<|im_start|>assistant
|
25 |
""")
|
26 |
-
llm = prompt | HuggingFacePipeline.from_model_id(
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
task="text-generation",
|
29 |
-
|
30 |
-
|
31 |
-
},
|
32 |
)
|
33 |
|
34 |
# llm = prompt | CustomLLM(repo_id="Qwen/Qwen-VL-Chat", model_type='text-generation', api_token=API_TOKEN, max_new_tokens=150).bind(stop=['<|im_end|>'])
|
|
|
7 |
from pydantic import BaseModel
|
8 |
from langchain.prompts import PromptTemplate
|
9 |
from langchain_huggingface import HuggingFacePipeline
|
10 |
+
from langchain_huggingface import HuggingFaceEndpoint
|
11 |
|
12 |
|
13 |
class ConversationPost(BaseModel):
|
|
|
17 |
|
18 |
|
19 |
API_TOKEN = os.environ['HF_API_KEY']
|
20 |
+
|
21 |
+
os.environ["HUGGINGFACEHUB_API_TOKEN"] = API_TOKEN
|
22 |
+
|
23 |
app = FastAPI()
|
24 |
prompt = PromptTemplate.from_template("""<|im_start|>system
|
25 |
+
Kamu adalah Asisten AI yang dikembangkan oleh Jonthan Jordan. Answer strictly in Bahasa Indonesia<|im_end|>
|
26 |
<|im_start|>user
|
27 |
{question}<|im_end|>
|
28 |
<|im_start|>assistant
|
29 |
""")
|
30 |
+
# llm = prompt | HuggingFacePipeline.from_model_id(
|
31 |
+
# model_id="Qwen/Qwen2-1.5B-Instruct",
|
32 |
+
# task="text-generation",
|
33 |
+
# pipeline_kwargs={
|
34 |
+
# "max_new_tokens": 150,
|
35 |
+
# "return_full_text":False
|
36 |
+
# },
|
37 |
+
# )
|
38 |
+
|
39 |
+
llm = prompt | HuggingFaceEndpoint(
|
40 |
+
repo_id="Qwen/Qwen-VL-Chat",
|
41 |
task="text-generation",
|
42 |
+
max_new_tokens=150,
|
43 |
+
do_sample=False,
|
|
|
44 |
)
|
45 |
|
46 |
# llm = prompt | CustomLLM(repo_id="Qwen/Qwen-VL-Chat", model_type='text-generation', api_token=API_TOKEN, max_new_tokens=150).bind(stop=['<|im_end|>'])
|