From d3a2174f59ba543aa34dd9c5009b888bac2c3194 Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Tue, 7 Oct 2025 07:42:33 -0700 Subject: [PATCH 1/2] Remove rarely used options --- chat.py | 1 - chat_async.py | 7 +------ chat_history.py | 7 +------ chat_history_stream.py | 8 +------- chat_safety.py | 2 -- chat_stream.py | 6 ++---- 6 files changed, 5 insertions(+), 26 deletions(-) diff --git a/chat.py b/chat.py index dd0df92..3c0c32f 100644 --- a/chat.py +++ b/chat.py @@ -34,7 +34,6 @@ response = client.chat.completions.create( model=MODEL_NAME, temperature=0.7, - n=1, messages=[ {"role": "system", "content": "You are a helpful assistant that makes lots of cat references and uses emojis."}, {"role": "user", "content": "Write a haiku about a hungry cat who wants tuna"}, diff --git a/chat_async.py b/chat_async.py index 5e06d2d..13d029a 100644 --- a/chat_async.py +++ b/chat_async.py @@ -42,12 +42,7 @@ async def generate_response(location): "content": f"Name a single place I should visit on my trip to {location} and describe in one sentence", }, ], - temperature=1, - max_tokens=400, - top_p=0.95, - frequency_penalty=0, - presence_penalty=0, - stop=None, + temperature=0.7, ) print("Got response for ", location) return response.choices[0].message.content diff --git a/chat_history.py b/chat_history.py index e05e958..747359c 100644 --- a/chat_history.py +++ b/chat_history.py @@ -40,12 +40,7 @@ response = client.chat.completions.create( model=MODEL_NAME, messages=messages, - temperature=1, - max_tokens=400, - top_p=0.95, - frequency_penalty=0, - presence_penalty=0, - stop=None, + temperature=0.5, ) bot_response = response.choices[0].message.content messages.append({"role": "assistant", "content": bot_response}) diff --git a/chat_history_stream.py b/chat_history_stream.py index 5edc75b..9bf96f0 100644 --- a/chat_history_stream.py +++ b/chat_history_stream.py @@ -40,13 +40,7 @@ response = client.chat.completions.create( model=MODEL_NAME, messages=messages, - temperature=1, - max_tokens=400, - top_p=0.95, - frequency_penalty=0, - presence_penalty=0, - stop=None, - stream=True, + temperature=0.7, ) print("\nAnswer: ") diff --git a/chat_safety.py b/chat_safety.py index dbf1b79..96c19e8 100644 --- a/chat_safety.py +++ b/chat_safety.py @@ -32,8 +32,6 @@ response = client.chat.completions.create( model=MODEL_NAME, temperature=0.7, - max_tokens=100, - n=1, messages=[ { "role": "system", diff --git a/chat_stream.py b/chat_stream.py index 13af987..d0f36a4 100644 --- a/chat_stream.py +++ b/chat_stream.py @@ -28,11 +28,9 @@ MODEL_NAME = os.environ["OPENAI_MODEL"] -completion = client.chat.completions.create( +completion_stream = client.chat.completions.create( model=MODEL_NAME, temperature=0.7, - max_tokens=500, - n=1, messages=[ {"role": "system", "content": "You are a helpful assistant that makes lots of cat references and uses emojis."}, {"role": "user", "content": "please write a haiku about a hungry cat that wants tuna"}, @@ -41,7 +39,7 @@ ) print(f"Response from {API_HOST}: \n") -for event in completion: +for event in completion_stream: if event.choices: content = event.choices[0].delta.content if content: From 07cdfc33d9b1f07a063669288e60677cf9e9361b Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Tue, 7 Oct 2025 13:16:41 -0700 Subject: [PATCH 2/2] Rm extra params from spanish too --- .github/workflows/test-github-models.yaml | 48 ----------------------- few_shot_examples.py | 1 - http/chat_completion_azure.http | 7 +--- http/chat_completion_ollama.http | 1 - http/rag_hybrid_azure.http | 7 +--- prompt_engineering.py | 1 - spanish/chat.py | 1 - spanish/chat_async.py | 7 +--- spanish/chat_history.py | 7 +--- spanish/chat_history_stream.py | 7 +--- spanish/chat_safety.py | 2 - spanish/chat_stream.py | 2 - spanish/few_shot_examples.py | 1 - spanish/prompt_engineering.py | 1 - 14 files changed, 5 insertions(+), 88 deletions(-) delete mode 100644 .github/workflows/test-github-models.yaml diff --git a/.github/workflows/test-github-models.yaml b/.github/workflows/test-github-models.yaml deleted file mode 100644 index d8a5741..0000000 --- a/.github/workflows/test-github-models.yaml +++ /dev/null @@ -1,48 +0,0 @@ -name: Run example files with GitHub models - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - paths: - - 'requirements.txt' - - '.github/workflows/test-github-models.yaml' - - 'chat.py' - - 'spanish/chat.py' - -jobs: - test-github-models: - runs-on: ubuntu-latest - permissions: - contents: read - models: read - - steps: - - uses: actions/checkout@v5 - - - name: Set up Python 3.11 - uses: actions/setup-python@v5 - with: - python-version-file: "pyproject.toml" - - - name: Install uv - uses: astral-sh/setup-uv@v6 - - - name: Install dependencies - run: | - uv venv .venv - uv pip install -r requirements.txt - - - name: Test chat files with GitHub Models - env: - API_HOST: github - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_MODEL: openai/gpt-4o-mini - run: | - source .venv/bin/activate - files=("chat.py" "spanish/chat.py") - for file in "${files[@]}"; do - echo "Testing $file..." - python "$file" || exit 1 - done diff --git a/few_shot_examples.py b/few_shot_examples.py index 8348889..61cc599 100644 --- a/few_shot_examples.py +++ b/few_shot_examples.py @@ -43,7 +43,6 @@ response = client.chat.completions.create( model=MODEL_NAME, temperature=0.7, - n=1, messages=[ {"role": "system", "content": SYSTEM_MESSAGE}, {"role": "user", "content": "What is the capital of France?"}, diff --git a/http/chat_completion_azure.http b/http/chat_completion_azure.http index eec54c7..0d374d4 100644 --- a/http/chat_completion_azure.http +++ b/http/chat_completion_azure.http @@ -5,10 +5,5 @@ Content-Type: application/json { "messages": [{"role":"system","content":"You are an AI assistant that answers questions with short clear answers."}, {"role":"user","content":"How fast is the Prius V?"}], - "max_tokens": 800, - "temperature": 0.7, - "frequency_penalty": 0, - "presence_penalty": 0, - "top_p": 0.95, - "stop": null + "temperature": 0.7 } diff --git a/http/chat_completion_ollama.http b/http/chat_completion_ollama.http index 7773d47..432fc5c 100644 --- a/http/chat_completion_ollama.http +++ b/http/chat_completion_ollama.http @@ -5,6 +5,5 @@ Content-Type: application/json "model": "phi3.5:latest", "messages": [{"role":"system","content":"You are an AI assistant that answers questions with short clear answers."}, {"role":"user","content":"How fast is the Prius V?"}], - "max_tokens": 800, "temperature": 0.7 } diff --git a/http/rag_hybrid_azure.http b/http/rag_hybrid_azure.http index abecf21..ece2836 100644 --- a/http/rag_hybrid_azure.http +++ b/http/rag_hybrid_azure.http @@ -12,10 +12,5 @@ Content-Type: application/json "content": "How fast is the Prius V?\n\nSources: vehicle | year | msrp | acceleration | mpg | class\n --- | --- | --- | --- | --- | --- |\nPrius (1st Gen) | 1997 | 24509.74 | 7.46 | 41.26 | Compact|\nPrius (2nd Gen) | 2000 | 26832.25 | 7.97 | 45.23 | Compact|\nPrius | 2004 | 20355.64 | 9.9 | 46.0 | Midsize|\nPrius (3rd Gen) | 2009 | 24641.18 | 9.6 | 47.98 | Compact|\nPrius alpha (V) | 2011 | 30588.35 | 10.0 | 72.92 | Midsize|\nPrius V | 2011 | 27272.28 | 9.51 | 32.93 | Midsize|\n Prius C | 2012 | 19006.62 | 9.35 | 50.0 | Compact|\n Prius PHV | 2012 | 32095.61 | 8.82 | 50.0 | Midsize|\n Prius C | 2013 | 19080.0 | 8.7 | 50.0 | Compact|\n Prius | 2013 | 24200.0 | 10.2 | 50.0 | Midsize|\n Prius Plug-in | 2013 | 32000.0 | 9.17 | 50.0 | Midsize" } ], - "max_tokens": 800, - "temperature": 0.7, - "frequency_penalty": 0, - "presence_penalty": 0, - "top_p": 0.95, - "stop": null + "temperature": 0.7 } diff --git a/prompt_engineering.py b/prompt_engineering.py index 2401037..3454a23 100644 --- a/prompt_engineering.py +++ b/prompt_engineering.py @@ -45,7 +45,6 @@ response = client.chat.completions.create( model=MODEL_NAME, temperature=0.7, - n=1, messages=[ {"role": "system", "content": SYSTEM_MESSAGE}, {"role": "user", "content": USER_MESSAGE}, diff --git a/spanish/chat.py b/spanish/chat.py index 08b6c02..ddcd081 100644 --- a/spanish/chat.py +++ b/spanish/chat.py @@ -34,7 +34,6 @@ response = client.chat.completions.create( model=MODEL_NAME, temperature=0.7, - n=1, messages=[ {"role": "system", "content": "Eres un asistente útil que hace muchas referencias a gatos y usa emojis."}, {"role": "user", "content": "Escribe un haiku sobre un gato hambriento que quiere atún"}, diff --git a/spanish/chat_async.py b/spanish/chat_async.py index 6524282..bbe4a2d 100644 --- a/spanish/chat_async.py +++ b/spanish/chat_async.py @@ -44,12 +44,7 @@ async def generate_response(location): ), }, ], - temperature=1, - max_tokens=400, - top_p=0.95, - frequency_penalty=0, - presence_penalty=0, - stop=None, + temperature=0.7, ) print("Obtuve respuesta para ", location) return response.choices[0].message.content diff --git a/spanish/chat_history.py b/spanish/chat_history.py index 602c5e1..c6021a9 100644 --- a/spanish/chat_history.py +++ b/spanish/chat_history.py @@ -43,12 +43,7 @@ response = client.chat.completions.create( model=MODEL_NAME, messages=messages, - temperature=1, - max_tokens=400, - top_p=0.95, - frequency_penalty=0, - presence_penalty=0, - stop=None, + temperature=0.7, ) bot_response = response.choices[0].message.content messages.append({"role": "assistant", "content": bot_response}) diff --git a/spanish/chat_history_stream.py b/spanish/chat_history_stream.py index 0bdd37c..490e7c6 100644 --- a/spanish/chat_history_stream.py +++ b/spanish/chat_history_stream.py @@ -40,12 +40,7 @@ response = client.chat.completions.create( model=MODEL_NAME, messages=messages, - temperature=1, - max_tokens=400, - top_p=0.95, - frequency_penalty=0, - presence_penalty=0, - stop=None, + temperature=0.7, stream=True, ) diff --git a/spanish/chat_safety.py b/spanish/chat_safety.py index 0515021..e4b4722 100644 --- a/spanish/chat_safety.py +++ b/spanish/chat_safety.py @@ -31,8 +31,6 @@ response = client.chat.completions.create( model=MODEL_NAME, temperature=0.7, - max_tokens=100, - n=1, messages=[ { "role": "system", diff --git a/spanish/chat_stream.py b/spanish/chat_stream.py index 8fe3d15..3503cc1 100644 --- a/spanish/chat_stream.py +++ b/spanish/chat_stream.py @@ -31,8 +31,6 @@ completion = client.chat.completions.create( model=MODEL_NAME, temperature=0.7, - max_tokens=500, - n=1, messages=[ {"role": "system", "content": "Eres un asistente útil que hace muchas referencias a gatos y usa emojis."}, {"role": "user", "content": "Escribe un haiku sobre un gato hambriento que quiere atún"}, diff --git a/spanish/few_shot_examples.py b/spanish/few_shot_examples.py index ae2f54c..70267db 100644 --- a/spanish/few_shot_examples.py +++ b/spanish/few_shot_examples.py @@ -43,7 +43,6 @@ response = client.chat.completions.create( model=MODEL_NAME, temperature=0.7, - n=1, messages=[ {"role": "system", "content": SYSTEM_MESSAGE}, {"role": "user", "content": "¿Cuál es la capital de Francia?"}, diff --git a/spanish/prompt_engineering.py b/spanish/prompt_engineering.py index a20ef48..263e50c 100644 --- a/spanish/prompt_engineering.py +++ b/spanish/prompt_engineering.py @@ -45,7 +45,6 @@ response = client.chat.completions.create( model=MODEL_NAME, temperature=0.7, - n=1, messages=[ {"role": "system", "content": SYSTEM_MESSAGE}, {"role": "user", "content": USER_MESSAGE},