Skip to content

Commit 83cfaaa

Browse files
authored
Merge pull request #30 from pamelafox/copilot/fix-29
Replace Azure Inference URL with GitHub AI URL
2 parents 1c9cc58 + c75466c commit 83cfaaa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+118
-119
lines changed

chained_calls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
MODEL_NAME = os.environ["OLLAMA_MODEL"]
2525

2626
elif API_HOST == "github":
27-
client = openai.OpenAI(base_url="https://models.inference.ai.azure.com", api_key=os.environ["GITHUB_TOKEN"])
28-
MODEL_NAME = os.getenv("GITHUB_MODEL", "gpt-4o")
27+
client = openai.OpenAI(base_url="https://models.github.ai/inference", api_key=os.environ["GITHUB_TOKEN"])
28+
MODEL_NAME = os.getenv("GITHUB_MODEL", "openai/gpt-4o")
2929

3030
else:
3131
client = openai.OpenAI(api_key=os.environ["OPENAI_KEY"])

chat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
MODEL_NAME = os.environ["OLLAMA_MODEL"]
2525

2626
elif API_HOST == "github":
27-
client = openai.OpenAI(base_url="https://models.inference.ai.azure.com", api_key=os.environ["GITHUB_TOKEN"])
28-
MODEL_NAME = os.getenv("GITHUB_MODEL", "gpt-4o")
27+
client = openai.OpenAI(base_url="https://models.github.ai/inference", api_key=os.environ["GITHUB_TOKEN"])
28+
MODEL_NAME = os.getenv("GITHUB_MODEL", "openai/gpt-4o")
2929

3030
else:
3131
client = openai.OpenAI(api_key=os.environ["OPENAI_KEY"])

chat_async.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
client = openai.AsyncOpenAI(base_url=os.environ["OLLAMA_ENDPOINT"], api_key="nokeyneeded")
2424
MODEL_NAME = os.environ["OLLAMA_MODEL"]
2525
elif API_HOST == "github":
26-
client = openai.AsyncOpenAI(base_url="https://models.inference.ai.azure.com", api_key=os.environ["GITHUB_TOKEN"])
27-
MODEL_NAME = os.getenv("GITHUB_MODEL", "gpt-4o")
26+
client = openai.AsyncOpenAI(base_url="https://models.github.ai/inference", api_key=os.environ["GITHUB_TOKEN"])
27+
MODEL_NAME = os.getenv("GITHUB_MODEL", "openai/gpt-4o")
2828
else:
2929
client = openai.AsyncOpenAI(api_key=os.environ["OPENAI_KEY"])
3030
MODEL_NAME = os.environ["OPENAI_MODEL"]

chat_history.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
client = openai.OpenAI(base_url=os.environ["OLLAMA_ENDPOINT"], api_key="nokeyneeded")
2323
MODEL_NAME = os.environ["OLLAMA_MODEL"]
2424
elif API_HOST == "github":
25-
client = openai.OpenAI(base_url="https://models.inference.ai.azure.com", api_key=os.environ["GITHUB_TOKEN"])
26-
MODEL_NAME = os.getenv("GITHUB_MODEL", "gpt-4o")
25+
client = openai.OpenAI(base_url="https://models.github.ai/inference", api_key=os.environ["GITHUB_TOKEN"])
26+
MODEL_NAME = os.getenv("GITHUB_MODEL", "openai/gpt-4o")
2727
else:
2828
client = openai.OpenAI(api_key=os.environ["OPENAI_KEY"])
2929
MODEL_NAME = os.environ["OPENAI_MODEL"]

chat_history_stream.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
client = openai.OpenAI(base_url=os.environ["OLLAMA_ENDPOINT"], api_key="nokeyneeded")
2323
MODEL_NAME = os.environ["OLLAMA_MODEL"]
2424
elif API_HOST == "github":
25-
client = openai.OpenAI(base_url="https://models.inference.ai.azure.com", api_key=os.environ["GITHUB_TOKEN"])
26-
MODEL_NAME = os.getenv("GITHUB_MODEL", "gpt-4o")
25+
client = openai.OpenAI(base_url="https://models.github.ai/inference", api_key=os.environ["GITHUB_TOKEN"])
26+
MODEL_NAME = os.getenv("GITHUB_MODEL", "openai/gpt-4o")
2727
else:
2828
client = openai.OpenAI(api_key=os.environ["OPENAI_KEY"])
2929
MODEL_NAME = os.environ["OPENAI_MODEL"]

chat_langchain.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
)
2828
elif API_HOST == "github":
2929
llm = ChatOpenAI(
30-
model_name=os.getenv("GITHUB_MODEL", "gpt-4o"),
31-
openai_api_base="https://models.inference.ai.azure.com",
30+
model_name=os.getenv("GITHUB_MODEL", "openai/gpt-4o"),
31+
openai_api_base="https://models.github.ai/inference",
3232
openai_api_key=os.environ["GITHUB_TOKEN"],
3333
)
3434
else:

chat_llamaindex.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
)
3030
elif API_HOST == "github":
3131
llm = OpenAILike(
32-
model=os.getenv("GITHUB_MODEL", "gpt-4o"),
33-
api_base="https://models.inference.ai.azure.com",
32+
model=os.getenv("GITHUB_MODEL", "openai/gpt-4o"),
33+
api_base="https://models.github.ai/inference",
3434
api_key=os.environ["GITHUB_TOKEN"],
3535
is_chat_model=True,
3636
)

chat_pydanticai.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
import azure.identity
44
from dotenv import load_dotenv
5-
from openai import AsyncAzureOpenAI
5+
from openai import AsyncAzureOpenAI, AsyncOpenAI
66
from pydantic_ai import Agent
77
from pydantic_ai.models.openai import OpenAIModel
8+
from pydantic_ai.providers.openai import OpenAIProvider
89

910
# Setup the OpenAI client to use either Azure, OpenAI.com, or Ollama API
1011
load_dotenv(override=True)
@@ -21,16 +22,14 @@
2122
)
2223
model = OpenAIModel(os.environ["AZURE_OPENAI_DEPLOYMENT"], openai_client=client)
2324
elif API_HOST == "ollama":
24-
model = OpenAIModel(os.environ["OLLAMA_MODEL"], api_key="fake", base_url=os.environ["OLLAMA_ENDPOINT"])
25+
client = AsyncOpenAI(base_url=os.environ["OLLAMA_ENDPOINT"], api_key="fake")
26+
model = OpenAIModel(os.environ["OLLAMA_MODEL"], provider=OpenAIProvider(openai_client=client))
2527
elif API_HOST == "github":
26-
model = OpenAIModel(
27-
os.getenv("GITHUB_MODEL", "gpt-4o"),
28-
api_key=os.environ["GITHUB_TOKEN"],
29-
base_url="https://models.inference.ai.azure.com",
30-
)
31-
28+
client = AsyncOpenAI(api_key=os.environ["GITHUB_TOKEN"], base_url="https://models.github.ai/inference")
29+
model = OpenAIModel(os.getenv("GITHUB_MODEL", "openai/gpt-4o"), provider=OpenAIProvider(openai_client=client))
3230
else:
33-
model = OpenAIModel(os.environ["OPENAI_MODEL"], api_key=os.environ["OPENAI_KEY"])
31+
client = AsyncOpenAI(api_key=os.environ["OPENAI_KEY"])
32+
model = OpenAIModel(os.environ["OPENAI_MODEL"], provider=OpenAIProvider(openai_client=client))
3433

3534

3635
agent = Agent(model, system_prompt="You are a helpful assistant that makes lots of cat references and uses emojis.")

chat_safety.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
client = openai.OpenAI(base_url=os.environ["OLLAMA_ENDPOINT"], api_key="nokeyneeded")
2323
MODEL_NAME = os.environ["OLLAMA_MODEL"]
2424
elif API_HOST == "github":
25-
client = openai.OpenAI(base_url="https://models.inference.ai.azure.com", api_key=os.environ["GITHUB_TOKEN"])
26-
MODEL_NAME = os.getenv("GITHUB_MODEL", "gpt-4o")
25+
client = openai.OpenAI(base_url="https://models.github.ai/inference", api_key=os.environ["GITHUB_TOKEN"])
26+
MODEL_NAME = os.getenv("GITHUB_MODEL", "openai/gpt-4o")
2727
else:
2828
client = openai.OpenAI(api_key=os.environ["OPENAI_KEY"])
2929
MODEL_NAME = os.environ["OPENAI_MODEL"]

chat_stream.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
client = openai.OpenAI(base_url=os.environ["OLLAMA_ENDPOINT"], api_key="nokeyneeded")
2323
MODEL_NAME = os.environ["OLLAMA_MODEL"]
2424
elif API_HOST == "github":
25-
client = openai.OpenAI(base_url="https://models.inference.ai.azure.com", api_key=os.environ["GITHUB_TOKEN"])
26-
MODEL_NAME = os.getenv("GITHUB_MODEL", "gpt-4o")
25+
client = openai.OpenAI(base_url="https://models.github.ai/inference", api_key=os.environ["GITHUB_TOKEN"])
26+
MODEL_NAME = os.getenv("GITHUB_MODEL", "openai/gpt-4o")
2727
else:
2828
client = openai.OpenAI(api_key=os.environ["OPENAI_KEY"])
2929
MODEL_NAME = os.environ["OPENAI_MODEL"]

0 commit comments

Comments
 (0)