-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c42a2e5
commit 39e4cc6
Showing
5 changed files
with
72 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import logging | ||
from log10.feedback.feedback_task import FeedbackTask | ||
|
||
httpx_logger = logging.getLogger("httpx") | ||
httpx_logger.setLevel(logging.DEBUG) | ||
|
||
feedback_task = FeedbackTask() | ||
t_s = { | ||
"type": "object", | ||
"properties": { | ||
"feedback": { | ||
"type": "string", | ||
"enum": ["😀", "😬", "😐", "🙁", "😫"] | ||
} | ||
} | ||
} | ||
# convert t_s to json | ||
import json | ||
t_s = json.dumps(t_s) | ||
task = feedback_task.create(name="emo", task_schema=t_s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from pprint import pprint | ||
from typing import Literal | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
from log10.feedback.feedback import Feedback | ||
from log10.feedback.feedback_task import FeedbackTask | ||
from log10.load import OpenAI | ||
|
||
|
||
class EmojiFeedback(BaseModel): | ||
feedback: Literal["😀", "🙁"] = Field(..., description="User feedback with emojis") | ||
|
||
|
||
client = OpenAI() | ||
completion = client.chat.completions.create( | ||
model="gpt-3.5-turbo", | ||
messages=[ | ||
{ | ||
"role": "system", | ||
"content": "You are the most knowledgable Star Wars guru on the planet", | ||
}, | ||
{ | ||
"role": "user", | ||
"content": "Write the time period of all the Star Wars movies and spinoffs?", | ||
}, | ||
], | ||
) | ||
completion_id = completion.choices[0].id | ||
|
||
task = FeedbackTask() | ||
res = task.create(name="emoji_feedback_task", task_schema=EmojiFeedback.model_json_schema()) | ||
task_id = res["id"] | ||
pprint(task) | ||
# Example usage | ||
fb = Feedback() | ||
res = fb.create(task_id=task_id, data=EmojiFeedback(feedback="😀").model_dump_json(), completion_tags_selector=[str(completion_id)]) | ||
pprint(res) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters