From 1c3770a64847ed3bf6aaf941971c15b672f09c87 Mon Sep 17 00:00:00 2001 From: Tomasz Rewak Date: Sat, 13 May 2023 20:56:09 +0200 Subject: [PATCH] Experimenting with classification prompt. --- main.py | 18 +++++++++++++++++- playground.py | 29 ++++++++++++++++++++++++----- requirements.txt | 1 + 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index 5ac7523..97976dd 100644 --- a/main.py +++ b/main.py @@ -1,10 +1,26 @@ -from dash import Dash, Input, Output +from dataclasses import dataclass +from dash_extensions.enrich import Dash, Input, Output, callback import dash_core_components as dcc import dash_html_components as html from dash_local_react_components import load_react_component app = Dash(__name__) + +@dataclass +class WiseManDefinition: + id: str + name: str + order_number: int + system_prompt: str + + +wise_man = [ + WiseManDefinition(id='melchior', name='MELCHIOR', order_number=1, system_prompt='You are a wise man'), + WiseManDefinition(id='baltasar', name='BALTASAR', order_number=2, system_prompt='You are a wise man'), + WiseManDefinition(id='casper', name='CASPAR', order_number=3, system_prompt='You are a wise man'), +] + Magi = load_react_component(app, 'components', 'magi.js') WiseMan = load_react_component(app, 'components', 'wise_man.js') diff --git a/playground.py b/playground.py index e17d155..adb60cc 100644 --- a/playground.py +++ b/playground.py @@ -3,12 +3,31 @@ import openai response = openai.ChatCompletion.create( model="gpt-3.5-turbo", messages=[ - {"role": "system", "content": "You are a helpful assistant."}, - {"role": "user", "content": "Who won the world series in 2020?"}, - {"role": "assistant", - "content": "The Los Angeles Dodgers won the World Series in 2020."}, - {"role": "user", "content": "Where was it played?"} + {"role": "system", "content": "You answer questions with a simple 'yes' or 'no'."}, + {"role": "user", "content": "Can the following question be generally answered with a 'yes' or 'no'? \n Is C# better than Java?"}, ] ) +# { +# "choices": [ +# { +# "finish_reason": "stop", +# "index": 0, +# "message": { +# "content": "Yes.", +# "role": "assistant" +# } +# } +# ], +# "created": 1684003959, +# "id": "chatcmpl-7Foe7sKt2SqEWcjmI5VG9Jc5ndRrd", +# "model": "gpt-3.5-turbo-0301", +# "object": "chat.completion", +# "usage": { +# "completion_tokens": 2, +# "prompt_tokens": 50, +# "total_tokens": 52 +# } +# } + print(response) diff --git a/requirements.txt b/requirements.txt index 01b9657..2f04ae0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ dash==2.9.3 +dash-extensions==1.0.0 dash-local-react-components==1.3.0 openai==0.27.6 \ No newline at end of file