ghus75 commited on
Commit
1b9db8f
·
1 Parent(s): f254bad

test calling demo from private repo

Browse files
Files changed (1) hide show
  1. app.py +3 -39
app.py CHANGED
@@ -1,44 +1,8 @@
 
1
  import gradio as gr
2
 
3
- from langchain_core.messages import HumanMessage, SystemMessage
4
- from langchain_huggingface import HuggingFaceEndpoint, ChatHuggingFace
5
-
6
- import os
7
  HF_Hub_API_token = os.environ.get('HF_Hub_API_token', None)
 
8
 
9
- llm = HuggingFaceEndpoint(
10
- repo_id="mistralai/Mistral-7B-Instruct-v0.2",
11
- task="text-generation",
12
- max_new_tokens=128,
13
- do_sample=False,
14
- repetition_penalty=1.03,
15
- huggingfacehub_api_token=HF_Hub_API_token
16
- )
17
-
18
- chat_model = ChatHuggingFace(llm=llm)
19
-
20
- MAX_LEN = 100
21
- def gen_prompt1(title):
22
- prompt1 = title
23
- formatted_str = ''
24
- if len(title) > 0:
25
- messages = [HumanMessage(content=prompt1),]
26
- res = chat_model.invoke(messages)
27
- # censure
28
- for s in res.content.split('\n'):
29
- if len(s) > MAX_LEN:
30
- s = s[:MAX_LEN] + " (...)"
31
- formatted_str += s + '\n'
32
-
33
- return formatted_str #res.content
34
-
35
- example_title = "Mary had a little lamb"
36
-
37
- demo = gr.Interface(
38
- fn=gen_prompt1,
39
- inputs=gr.Textbox(label = "Introduction", show_label=True),
40
- outputs=["text"],
41
- examples=[example_title]
42
- )
43
-
44
  demo.launch()
 
1
+ import os
2
  import gradio as gr
3
 
 
 
 
 
4
  HF_Hub_API_token = os.environ.get('HF_Hub_API_token', None)
5
+ import gradio as gr
6
 
7
+ demo = gr.load("gaelhuser/patent_gen_prv", hf_token=HF_Hub_API_token, src="spaces")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  demo.launch()