pentagoniac's picture
Update app.py
0b2b568 verified
raw
history blame contribute delete
No virus
4.37 kB
import argparse
import gradio as gr
from openai import OpenAI
MODEL = "pentagoniac/SEMIKONG-8b-GPTQ"
def http_bot(prompt, history):
messages = []
prompt_final = f"""You are SEMIKONG, an AI Assistant developed by the AI Alliance.
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.
You must use as much as technical term as possible to make the answer more professional and informative.
Your answer must align with these criteria:
1. Clarity and Structure: Assess the logical structure and clarity of the presentation. Determine if the answer is organized in a way that makes it easy to follow and understand, regardless of the question's complexity.
2. Accuracy and Depth of Knowledge: Evaluate the technical accuracy and depth of knowledge demonstrated in the answer. Check for precision and correctness in the information provided, ensuring it aligns with established principles and facts.
3. Precision in Terminology: Review the use of terminology within the answer. Ensure that terms are used precisely and specifically, enhancing the accuracy and professionalism of the response.
4. Causality and Correlation: Analyze the identification and explanation of causal relationships or correlations. This is crucial for effectively diagnosing problems, analyzing scenarios, and discussing theoretical principles.
5. Practicality and Applicability: Judge the practicality and applicability of the recommendations and solutions offered. Ensure they are tailored to the specific conditions of the question and are feasible in the given context.
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.
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.
Now given an instruction from : {prompt}.
Your answer: <your answer here>"""
messages.append({"role": "user", "content": prompt_final})
client = OpenAI(api_key="dummy", base_url="http://semikong.aitomatic.com:8081/v1")
response = client.chat.completions.create(
model=MODEL,
messages=messages,
# stream=True,
max_tokens=1024,
temperature=0.0,
n=1,
presence_penalty=0.7,
top_p=1.0,
extra_body={
"frequency_penalty": 0.5,
"repetition_penalty": 1.0,
"length_penalty": 1.0,
"top_k": 50,
"min_p": 0.8,
"best_of": 1,
"use_beam_search": False,
"early_stopping": False,
},
)
# Extract the answer from the response
answer = response.choices[0].message.content
# Return the answer
return answer
css = """
<style>
.centered-content {
text-align: center;
margin: auto;
max-width: 800px;
}
.centered-content h2 {
color: #333;
margin-bottom: 20px;
}
.centered-content p {
color: #666;
line-height: 1.6;
}
</style>
"""
description = (
css
+ """
<div class="centered-content">
<h2>The world's first open-source LLM designed specifically for the semiconductor industry.</h2>
<p>SemiKong is a collaborative open-source effort with support from Aitomatic, TEL, FPT AI Center, The AI Alliance</p>
</div>
"""
)
def build_demo():
demo = gr.ChatInterface(
http_bot,
chatbot=gr.Chatbot(height=600),
textbox=gr.Textbox(
placeholder="Ask SEMIKONG something", container=False, scale=7
),
title="SEMIKONG-8B-GPTQ",
description=description,
theme="soft",
cache_examples=False,
retry_btn=None,
undo_btn="Delete Previous",
clear_btn="Clear",
)
return demo
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--host", type=str, default=None)
parser.add_argument("--port", type=int, default=8001)
args = parser.parse_args()
demo = build_demo()
demo.queue().launch()