zerostratos commited on
Commit
40db491
·
verified ·
1 Parent(s): 64438ee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -3
app.py CHANGED
@@ -1,5 +1,51 @@
1
- #import gradio as gr
 
 
 
 
 
2
  from huggingface_hub import InferenceClient
3
- client = InferenceClient("thviet79/model-QA-medical")
4
 
5
- client.question_answering(question="Hi?",context = "greeting")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #pip install huggingface_hub
2
+
3
+ #export HF_TOKEN="<>"
4
+
5
+
6
+
7
  from huggingface_hub import InferenceClient
 
8
 
9
+ import json
10
+
11
+
12
+
13
+ repo_id = "TinyLlama/TinyLlama-1.1B-Chat-v1.0"
14
+
15
+
16
+
17
+ llm_client = InferenceClient(
18
+
19
+ model=repo_id,
20
+
21
+ timeout=120,
22
+
23
+ )
24
+
25
+
26
+
27
+ def call_llm(inference_client: InferenceClient, prompt: str):
28
+
29
+ response = inference_client.post(
30
+
31
+ json={
32
+
33
+ "inputs": prompt,
34
+
35
+ "parameters": {"max_new_tokens": 200},
36
+
37
+ "task": "text-generation",
38
+
39
+ },
40
+
41
+ )
42
+
43
+ return json.loads(response.decode())[0]["generated_text"]
44
+
45
+
46
+
47
+
48
+
49
+ response=call_llm(llm_client, "write me a crazy joke")
50
+
51
+ print (response)