Spaces:
Runtime error
Runtime error
pentagoniac
commited on
Commit
•
0b3e6f7
1
Parent(s):
bbb7699
Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,19 @@
|
|
1 |
import argparse
|
2 |
-
import json
|
3 |
-
|
4 |
import gradio as gr
|
5 |
-
|
|
|
|
|
|
|
6 |
|
7 |
|
8 |
def http_bot(prompt, history):
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
12 |
Your role is to use your's in-depth knowledge in the field of Semiconductor Manufacturing Process to answer the instruction from the user in the most sophisticate, detail and technical ways.
|
13 |
You must use as much as technical term as possible to make the answer more professional and informative.
|
14 |
Your answer must align with these criteria:
|
@@ -20,33 +25,36 @@ Your answer must align with these criteria:
|
|
20 |
6. Comprehensive Coverage: Verify that the answer addresses all relevant aspects of the question. The response should be thorough, covering multiple angles and potential outcomes suitable for the type of question asked.
|
21 |
7. Relevance to the Question: Confirm that the content of the answer directly addresses the core of the question. All explanations and solutions should be relevant and specifically tailored to the details and constraints of the question.
|
22 |
Now given an instruction from : {prompt}.
|
23 |
-
Your answer: <your answer here>
|
24 |
-
|
25 |
-
"stream": True,
|
26 |
-
"max_tokens": 1024,
|
27 |
-
"temperature": 0.0,
|
28 |
-
"presence_penalty": 0.7,
|
29 |
-
"frequency_penalty": 0.5,
|
30 |
-
"repetition_penalty": 1.0,
|
31 |
-
"length_penalty": 1.0,
|
32 |
-
"top_p": 1.0,
|
33 |
-
"top_k": 50,
|
34 |
-
"min_p": 0.8,
|
35 |
-
"n": 1,
|
36 |
-
"best_of": 1,
|
37 |
-
"use_beam_search": False,
|
38 |
-
"early_stopping": False,
|
39 |
-
}
|
40 |
-
response = requests.post(args.model_url, headers=headers, json=pload, stream=True)
|
41 |
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
|
52 |
def build_demo():
|
@@ -64,10 +72,9 @@ For open-source repository, please refer to: __TBA__
|
|
64 |
""",
|
65 |
theme="soft",
|
66 |
examples=[
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
"What elements are necessary for miniaturization of semiconductor etch manufacturing equipment and what are their priorities?",
|
71 |
],
|
72 |
cache_examples=True,
|
73 |
retry_btn=None,
|
@@ -79,12 +86,9 @@ For open-source repository, please refer to: __TBA__
|
|
79 |
|
80 |
if __name__ == "__main__":
|
81 |
parser = argparse.ArgumentParser()
|
82 |
-
parser.add_argument(
|
83 |
-
|
84 |
-
type=str,
|
85 |
-
default="https://u8lkrlhamyqws0-8000.proxy.runpod.net/generate",
|
86 |
-
)
|
87 |
args = parser.parse_args()
|
88 |
|
89 |
demo = build_demo()
|
90 |
-
demo.queue().launch()
|
|
|
1 |
import argparse
|
|
|
|
|
2 |
import gradio as gr
|
3 |
+
|
4 |
+
from openai import OpenAI
|
5 |
+
|
6 |
+
CLIENT = OpenAI(api_key="dummy", base_url="http://34.125.92.207:8081/v1")
|
7 |
|
8 |
|
9 |
def http_bot(prompt, history):
|
10 |
+
# Convert history to the format expected by the OpenAI API
|
11 |
+
# messages = [{"role": "user" if item['is_user'] else "assistant", "content": item['content']} for item in history]
|
12 |
+
messages = []
|
13 |
+
|
14 |
+
# Add the current prompt to the messages
|
15 |
+
|
16 |
+
prompt_final = f"""You are SEMIKONG, an AI Assistant developed by the AI Alliance.
|
17 |
Your role is to use your's in-depth knowledge in the field of Semiconductor Manufacturing Process to answer the instruction from the user in the most sophisticate, detail and technical ways.
|
18 |
You must use as much as technical term as possible to make the answer more professional and informative.
|
19 |
Your answer must align with these criteria:
|
|
|
25 |
6. Comprehensive Coverage: Verify that the answer addresses all relevant aspects of the question. The response should be thorough, covering multiple angles and potential outcomes suitable for the type of question asked.
|
26 |
7. Relevance to the Question: Confirm that the content of the answer directly addresses the core of the question. All explanations and solutions should be relevant and specifically tailored to the details and constraints of the question.
|
27 |
Now given an instruction from : {prompt}.
|
28 |
+
Your answer: <your answer here>"""
|
29 |
+
messages.append({"role": "user", "content": prompt_final})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
+
# Call the OpenAI API to generate a response
|
32 |
+
response = CLIENT.chat.completions.create(
|
33 |
+
model="sitloboi2012/SEMIKONG-70B-v2",
|
34 |
+
messages=messages,
|
35 |
+
# stream=True,
|
36 |
+
max_tokens=1024,
|
37 |
+
temperature=0.0,
|
38 |
+
n=1,
|
39 |
+
presence_penalty=0.7,
|
40 |
+
top_p=1.0,
|
41 |
+
extra_body={
|
42 |
+
"frequency_penalty": 0.5,
|
43 |
+
"repetition_penalty": 1.0,
|
44 |
+
"length_penalty": 1.0,
|
45 |
+
"top_k": 50,
|
46 |
+
"min_p": 0.8,
|
47 |
+
"best_of": 1,
|
48 |
+
"use_beam_search": False,
|
49 |
+
"early_stopping": False,
|
50 |
+
},
|
51 |
+
)
|
52 |
+
|
53 |
+
# Extract the answer from the response
|
54 |
+
answer = response.choices[0].message.content
|
55 |
+
|
56 |
+
# Return the answer
|
57 |
+
return answer
|
58 |
|
59 |
|
60 |
def build_demo():
|
|
|
72 |
""",
|
73 |
theme="soft",
|
74 |
examples=[
|
75 |
+
"Describe different type of etching in semiconductor manufacturing process",
|
76 |
+
"What is Photolithography ?",
|
77 |
+
"What elements are necessary for miniaturization of semiconductor etch manufacturing equipment and what are their priorities?",
|
|
|
78 |
],
|
79 |
cache_examples=True,
|
80 |
retry_btn=None,
|
|
|
86 |
|
87 |
if __name__ == "__main__":
|
88 |
parser = argparse.ArgumentParser()
|
89 |
+
parser.add_argument("--host", type=str, default=None)
|
90 |
+
parser.add_argument("--port", type=int, default=8001)
|
|
|
|
|
|
|
91 |
args = parser.parse_args()
|
92 |
|
93 |
demo = build_demo()
|
94 |
+
demo.queue().launch(server_name=args.host, server_port=args.port, share=True)
|