Skip to content

Commit

Permalink
Fix completions tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-XT committed May 6, 2024
1 parent a16aad4 commit 013e6d4
Showing 1 changed file with 13 additions and 33 deletions.
46 changes: 13 additions & 33 deletions tests/completions-tests.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
{
"cell_type": "code",
"execution_count": 63,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -37,7 +37,6 @@
"AGENT_NAME = \"gpt4free\"\n",
"AGIXT_SERVER = \"http://localhost:7437\"\n",
"AGIXT_API_KEY = os.getenv(\"AGIXT_API_KEY\", \"none\")\n",
"SYSTEM_MESSAGE = \"\"\n",
"DEFAULT_MAX_TOKENS = 256\n",
"DEFAULT_TEMPERATURE = 0.5\n",
"DEFAULT_TOP_P = 0.9\n",
Expand Down Expand Up @@ -65,20 +64,6 @@
" if \"http://localhost:8091/outputs/\" in content:\n",
" if outputs_url != \"http://localhost:8091/outputs/\":\n",
" content = content.replace(\"http://localhost:8091/outputs/\", outputs_url)\n",
" if \"<audio controls>\" in content or \" \" not in content:\n",
" import base64\n",
" from datetime import datetime\n",
"\n",
" try:\n",
" audio_response = content.split(\"data:audio/wav;base64,\")[1].split('\" type')[\n",
" 0\n",
" ]\n",
" except:\n",
" audio_response = content\n",
" file_name = f\"outputs/{datetime.now().strftime('%Y-%m-%d-%H-%M-%S')}.wav\"\n",
" with open(file_name, \"wb\") as fh:\n",
" fh.write(base64.b64decode(audio_response))\n",
" display(Audio(filename=file_name, autoplay=True))\n",
" if outputs_url in content:\n",
" urls = re.findall(f\"{re.escape(outputs_url)}[^\\\"' ]+\", content)\n",
" urls = urls[0].split(\"\\n\\n\")\n",
Expand All @@ -88,13 +73,13 @@
" data = requests.get(url, headers=HEADERS).content\n",
" if url.endswith(\".jpg\") or url.endswith(\".png\"):\n",
" content = content.replace(url, \"\")\n",
" display(Image(data=data))\n",
" display(Image(url=url))\n",
" elif url.endswith(\".mp4\"):\n",
" content = content.replace(url, \"\")\n",
" display(Video(data=data, autoplay=True))\n",
" display(Video(url=url, autoplay=True))\n",
" elif url.endswith(\".wav\"):\n",
" content = content.replace(url, \"\")\n",
" display(Audio(data=data, autoplay=True))\n",
" display(Audio(url=url, autoplay=True))\n",
" print(content)"
]
},
Expand Down Expand Up @@ -198,28 +183,24 @@
},
{
"cell_type": "code",
"execution_count": 66,
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"I'm glad you enjoyed the previous poems I wrote for Pikachu! Here's another short poem for you:\n",
"\n",
"In the vast world of Pokémon, a friend so true,\n",
"Pikachu, with a heart that's pure and new.\n",
"A jolt of joy, a surge of delight,\n",
"Beneath the moon or the warm sunlight.\n",
"I'm glad you enjoyed the poem about Pikachu! While I can't provide pictures, I can certainly offer another creative piece about this beloved Pokémon. Here's a haiku to complement the previous poem:\n",
"\n",
"With every battle, it shows its might,\n",
"A beacon of hope, in the darkest night.\n",
"A cherished companion, through thick and thin,\n",
"Pikachu, the beloved, forever our kin.\n",
"```markdown\n",
"Yellow spark ignites,\n",
"Thunder's friend leaps with delight,\n",
"Pikachu's heart shines.\n",
"```\n",
"\n",
"As for the picture, I'm still unable to see it. If you could provide the image, I would be happy to describe each stage or element as you requested. If you have any other questions or need further assistance, please let me know!\n",
"I hope this haiku adds a little more spark to your day! If you have any more requests or need assistance with something else, feel free to let me know. 😊\n",
"\n",
"Today's date is March 31, 2024 08:33 PM.\n"
"<audio controls><source src=\"https://api.agixt.chat/outputs/f3bc95c54fcd4d98987e3d70a304ca2b.wav\" type=\"audio/wav\"></audio>\n"
]
}
],
Expand All @@ -235,7 +216,6 @@
" max_tokens=DEFAULT_MAX_TOKENS,\n",
" top_p=DEFAULT_TOP_P,\n",
" stream=False,\n",
" extra_body={\"system_message\": SYSTEM_MESSAGE},\n",
")\n",
"display_content(response.choices[0].message.content)"
]
Expand Down

0 comments on commit 013e6d4

Please sign in to comment.