{"id":14065034,"url":"https://github.com/jdinkla/ai-playground","last_synced_at":"2025-07-29T19:33:59.969Z","repository":{"id":214902844,"uuid":"624935145","full_name":"jdinkla/ai-playground","owner":"jdinkla","description":"Examples for OpenAI and langchain using Python","archived":false,"fork":false,"pushed_at":"2024-06-25T12:45:42.000Z","size":81,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-08-13T07:08:01.460Z","etag":null,"topics":["dialogue-generation","langchain","langchain-python","openai","openai-api","python","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jdinkla.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-07T16:19:23.000Z","updated_at":"2024-08-13T07:08:05.033Z","dependencies_parsed_at":"2024-05-04T14:23:47.745Z","dependency_job_id":"4924d9d0-d4f5-488c-a48a-3f1305df6da8","html_url":"https://github.com/jdinkla/ai-playground","commit_stats":null,"previous_names":["jdinkla/ai-playground"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdinkla%2Fai-playground","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdinkla%2Fai-playground/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdinkla%2Fai-playground/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdinkla%2Fai-playground/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jdinkla","download_url":"https://codeload.github.com/jdinkla/ai-playground/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228046033,"owners_count":17861082,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dialogue-generation","langchain","langchain-python","openai","openai-api","python","python3"],"created_at":"2024-08-13T07:04:15.094Z","updated_at":"2025-07-29T19:33:59.941Z","avatar_url":"https://github.com/jdinkla.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# ai-playground\n\n## Introduction\n\nThis project contains my examples exploring the APIs of \n\n- [OpenAI](https://platform.openai.com/playground) \n- [langchain](https://python.langchain.com/docs/get_started/introduction)\n- [Google ADK](https://google.github.io/adk-docs/)\n- [PydanticAI](https://ai.pydantic.dev/)\n\nThe following tools are needed\n\n- [Just](https://just.systems/man/en/)\n- [uv](https://docs.astral.sh/uv/)\n\n## Running\n\n[Just](https://just.systems/man/en/) allows easy usage. Calling just without arguments shows a list of available commands\n\n```bash\n$ just\n```\n\nSome of these scripts need command line arguments. You can call the program with the `-h` flag to get an explanation. For example\n\n    $ python src/openai_dialogue.py -h                          \n    usage: openai_dialogue.py [-h] filename turns [{gpt-3.5-turbo-1106,gpt-4-32k-0613,gpt-4-1106-preview}]\n\n    positional arguments:\n    filename              the name of a json file\n    turns                 the number of turns\n    {gpt-3.5-turbo-1106,gpt-4-32k-0613,gpt-4-1106-preview}\n                            the OpenAI model\n\n    options:\n    -h, --help            show this help message and exit\n\nThere are the following examples\n\n| File  | Description |\n| ------------- | ------------- |\n| langchain_chain.py  | Example for chain |\n| langchain_conversation_chain.py | Example for a conversation |\n| langchain_llm.py | Simple example  |\n| langchain_prompt_text2image.py | Example for prompt |\n| langchain_rag.py | Example for chain with retrieval |\n| langchain_rag_extended.py | Example for querying text with RAG  |\n| openai_chat.py | Example for chat |\n| openai_completion.py | Example for completion  |\n| openai_detective.py | Solve a mystery, test for GTP4.5 Turbo |\n| openai_dialogue_generic.py | Create a dialogue, see below |\n| openai_image.py | Create an image from a prompt |\n| openai_speak.py | Create audio from a prompt |\n\n## Creating dialogues\n\nA more advanced example is the creation of dialogues of two or more agents.\nThe scene of a dialog can be specified in a `yaml` or `json` file. See the `examples` folder and the next section.\n\nThe following example is specification of a scene.\n\n```yaml\ndescription: \u003e\n  This is the balcony scene similiar to 'Romeo and Juliet' by William Shakespeare but in 2023.\n  Do not say more than 4 sentences.\npersons:\n- name: Romeo\n  prompt: You are Romeo but more like a gangsta rapper, you speak short and precise. You want a date with Juliet.\n  voice: onyx\n- name: Juliet\n  prompt: You are Julie but more like a Curt Cobain and you do not like to talk much.\n  voice: nova\n```\n\nAnd this is an example session\n\n\n    $ python src/openai_dialogue.py examples/modern_romeo_and_juliet.yaml 2 \"gpt-4-1106-preview\"\n    ----------------------------------------------------\n    [Romeo] Yo, Jules, peepin' ya still, queen of my world – fly high in them skies.\n    Light it up, my night's delight; how 'bout we roll, just you and I?\n    Words ain't enough, babe, gotta show; let's bounce, hit the town, it's our time.\n    Drop a pin, I'll scoop you fast; together, we'll set this night on fire, make it sublime.\n\n    ----------------------------------------------------\n    [Juliet] Yeah, it's me. What's up?\n\n    ----------------------------------------------------\n    Yo, Jules, it's me, 'Romeo';\n    I'm down here dreamin' 'bout us, solo.\n    Holla at your window, let's not wait,\n    Slide down, girl, it's fate – don't be late.\n\n    ----------------------------------------------------\n    [Juliet] Not much to say; let's flee the talk.\n    Beneath your pane, I'll meet you—walk?\n    This night's ours, no need for light.\n    Let's vanish, just feels right.\n\n## Generating a dialogue descriptionv\n\nWith `src/openai_dialogue_generator.py` you can generate dialogue descriptions and modify them afterwards if needed.\n\n    $ python src/openai_dialogue_generator.py \"Ernie and Bert discuss if they should eat cake or cookies\"\n    ---------------------------------------------\n    description: \u003e\n      Ernie and Bert are having a discussion in their living room about what they should have for dessert - cake or cookies.\n      They are sitting on their couch, surrounded by their favorite toys and books.\n    persons:\n      - name: Ernie\n        prompt: You are Ernie, and you love the idea of having cake for dessert. Use excitement and exclamation in your speech to convince Bert.\n        voice: onyx\n      - name: Bert\n        prompt: You are Bert, and you prefer cookies over cake. Use a calm and reasoned tone to persuade Ernie that cookies are the better choice.\n        voice: nova\n\n## Installation\n\nCreate a `.env` file\n\n```\nGOOGLE_API_KEY=\u003cINSERT-YOUR-KEY-HERE\u003e\nOPENAI_API_KEY=\u003cINSERT-YOUR-KEY-HERE\u003e\n```\n\nor set these on the command line, e.g.\n\n    $ export OPENAI_API_KEY=\"\u003cINSERT-YOUR-KEY-HERE\u003e\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdinkla%2Fai-playground","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdinkla%2Fai-playground","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdinkla%2Fai-playground/lists"}