Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Semantic Router
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
aurelio-labs
Semantic Router
Commits
5a396202
Unverified
Commit
5a396202
authored
10 months ago
by
Siraj R Aizlewood
Browse files
Options
Downloads
Patches
Plain Diff
Linting and removal of temporary comparison __call__ in openai.py.
parent
307cc1b1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
semantic_router/llms/openai.py
+5
-23
5 additions, 23 deletions
semantic_router/llms/openai.py
with
5 additions
and
23 deletions
semantic_router/llms/openai.py
+
5
−
23
View file @
5a396202
...
@@ -68,36 +68,18 @@ class OpenAILLM(BaseLLM):
...
@@ -68,36 +68,18 @@ class OpenAILLM(BaseLLM):
)
)
arguments
=
tool_calls
[
0
].
function
.
arguments
arguments
=
tool_calls
[
0
].
function
.
arguments
if
arguments
is
None
:
if
arguments
is
None
:
raise
ValueError
(
"
Invalid output, expected arguments to be specified.
"
)
raise
ValueError
(
"
Invalid output, expected arguments to be specified.
"
)
output
=
str
(
arguments
)
# str to keep MyPy happy.
output
=
str
(
arguments
)
# str to keep MyPy happy.
else
:
else
:
content
=
completion
.
choices
[
0
].
message
.
content
content
=
completion
.
choices
[
0
].
message
.
content
if
content
is
None
:
if
content
is
None
:
raise
ValueError
(
"
Invalid output, expected content.
"
)
raise
ValueError
(
"
Invalid output, expected content.
"
)
output
=
str
(
content
)
# str to keep MyPy happy.
output
=
str
(
content
)
# str to keep MyPy happy.
return
output
except
Exception
as
e
:
logger
.
error
(
f
"
LLM error:
{
e
}
"
)
raise
Exception
(
f
"
LLM error:
{
e
}
"
)
from
e
def
__call__
(
self
,
messages
:
List
[
Message
])
->
str
:
if
self
.
client
is
None
:
raise
ValueError
(
"
OpenAI client is not initialized.
"
)
try
:
completion
=
self
.
client
.
chat
.
completions
.
create
(
model
=
self
.
name
,
messages
=
[
m
.
to_openai
()
for
m
in
messages
],
temperature
=
self
.
temperature
,
max_tokens
=
self
.
max_tokens
,
)
output
=
completion
.
choices
[
0
].
message
.
content
if
not
output
:
raise
Exception
(
"
No output generated
"
)
return
output
return
output
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
error
(
f
"
LLM error:
{
e
}
"
)
logger
.
error
(
f
"
LLM error:
{
e
}
"
)
raise
Exception
(
f
"
LLM error:
{
e
}
"
)
from
e
raise
Exception
(
f
"
LLM error:
{
e
}
"
)
from
e
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment