Skip to content

Commit

Permalink
rewrite text
Browse files Browse the repository at this point in the history
  • Loading branch information
eaidova committed Aug 5, 2024
1 parent d7ba7d8 commit 76da0f9
Show file tree
Hide file tree
Showing 4 changed files with 205 additions and 596 deletions.
3 changes: 3 additions & 0 deletions .ci/spellcheck/.pyspelling.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ autoregressive
autoregressively
AutoTokenizer
AWQ
awq
backend
backends
Baevski
Expand Down Expand Up @@ -391,6 +392,7 @@ KServe
Kubernetes
Kupyn
KV
KVCache
Labelling
labour
labse
Expand Down Expand Up @@ -617,6 +619,7 @@ Prateek
pre
Precisions
precomputed
preconverted
prefetching
preformatted
PrePostProcessing
Expand Down
55 changes: 27 additions & 28 deletions notebooks/llm-chatbot/genai_gradio_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,33 @@
core = ov.Core()

chinese_examples = [
["你好!"],
["你是谁?"],
["请介绍一下上海"],
["请介绍一下英特尔公司"],
["晚上睡不着怎么办?"],
["给我讲一个年轻人奋斗创业最终取得成功的故事。"],
["给这个故事起一个标题。"],
["你好!"],
["你是谁?"],
["请介绍一下上海"],
["请介绍一下英特尔公司"],
["晚上睡不着怎么办?"],
["给我讲一个年轻人奋斗创业最终取得成功的故事。"],
["给这个故事起一个标题。"],
]

english_examples = [
["Hello there! How are you doing?"],
["What is OpenVINO?"],
["Who are you?"],
["Can you explain to me briefly what is Python programming language?"],
["Explain the plot of Cinderella in a sentence."],
["What are some common mistakes to avoid when writing code?"],
["Write a 100-word blog post on “Benefits of Artificial Intelligence and OpenVINO“"],
["Hello there! How are you doing?"],
["What is OpenVINO?"],
["Who are you?"],
["Can you explain to me briefly what is Python programming language?"],
["Explain the plot of Cinderella in a sentence."],
["What are some common mistakes to avoid when writing code?"],
["Write a 100-word blog post on “Benefits of Artificial Intelligence and OpenVINO“"],
]

japanese_examples = [
["こんにちは!調子はどうですか?"],
["OpenVINOとは何ですか?"],
["あなたは誰ですか?"],
["Pythonプログラミング言語とは何か簡単に説明してもらえますか?"],
["シンデレラのあらすじを一文で説明してください。"],
["コードを書くときに避けるべきよくある間違いは何ですか?"],
["人工知能と「OpenVINOの利点」について100語程度のブログ記事を書いてください。"],
["こんにちは!調子はどうですか?"],
["OpenVINOとは何ですか?"],
["あなたは誰ですか?"],
["Pythonプログラミング言語とは何か簡単に説明してもらえますか?"],
["シンデレラのあらすじを一文で説明してください。"],
["コードを書くときに避けるべきよくある間違いは何ですか?"],
["人工知能と「OpenVINOの利点」について100語程度のブログ記事を書いてください。"],
]

DEFAULT_SYSTEM_PROMPT = """\
Expand All @@ -55,7 +55,11 @@


def get_system_prompt(model_language):
return DEFAULT_SYSTEM_PROMPT_CHINESE if (model_language == "Chinese") else DEFAULT_SYSTEM_PROMPT_JAPANESE if (model_language == "Japanese") else DEFAULT_SYSTEM_PROMPT
return (
DEFAULT_SYSTEM_PROMPT_CHINESE
if (model_language == "Chinese")
else DEFAULT_SYSTEM_PROMPT_JAPANESE if (model_language == "Japanese") else DEFAULT_SYSTEM_PROMPT
)


class TextQueue:
Expand Down Expand Up @@ -111,10 +115,8 @@ def default_partial_text_processor(partial_text: str, new_text: str):
partial_text += new_text
return partial_text


text_processor = model_configuration.get("partial_text_processor", default_partial_text_processor)


def bot(message, history, temperature, top_p, top_k, repetition_penalty):
"""
callback function for running chatbot on submit button click
Expand Down Expand Up @@ -168,13 +170,11 @@ def generate_and_signal_complete():
history[-1][1] = partial_text
yield "", history, streamer


def stop_chat(streamer):
if streamer is not None:
streamer.end()
return None


def stop_chat_and_clear_history(streamer):
if streamer is not None:
streamer.end()
Expand All @@ -183,7 +183,6 @@ def stop_chat_and_clear_history(streamer):

examples = chinese_examples if (model_language == "Chinese") else japanese_examples if (model_language == "Japanese") else english_examples


with gr.Blocks(
theme=gr.themes.Soft(),
css=".disclaimer {font-variant-caps: all-small-caps;}",
Expand Down Expand Up @@ -272,4 +271,4 @@ def stop_chat_and_clear_history(streamer):
stop.click(fn=stop_chat, inputs=streamer, outputs=[streamer], queue=False)
clear.click(fn=stop_chat_and_clear_history, inputs=streamer, outputs=[chatbot, streamer], queue=False)

return demo
return demo
Loading

0 comments on commit 76da0f9

Please sign in to comment.