Skip to content

Build and run agents you can see, understand and trust.

docs(api): abandon the API documentation temporarily (#1196)

DavdGao403bd27e06be
diff --git a/docs/tutorial/en/build.sh b/docs/tutorial/en/build.sh
index 9ea002d04..1158fa280 100755
--- a/docs/tutorial/en/build.sh
+++ b/docs/tutorial/en/build.sh
@@ -5,9 +5,6 @@ set -e
# Clean old build files
rm -rf build/ doctrees/
-# Generate the API rst files
-sphinx-apidoc -o api ../../../src/agentscope -t ../_templates -e
-
# Build the html
sphinx-build -M html ./ build
diff --git a/docs/tutorial/en/index.rst b/docs/tutorial/en/index.rst
index 0628b5ba5..b8450a5f7 100644
--- a/docs/tutorial/en/index.rst
+++ b/docs/tutorial/en/index.rst
@@ -73,27 +73,3 @@ Welcome to AgentScope's documentation!
tutorial/task_embedding
tutorial/task_tts
tutorial/task_tuner
-
-.. toctree::
- :maxdepth: 1
- :caption: API Docs
-
- api/agentscope
- api/agentscope.message
- api/agentscope.model
- api/agentscope.formatter
- api/agentscope.module
- api/agentscope.pipeline
- api/agentscope.agent
- api/agentscope.memory
- api/agentscope.tool
- api/agentscope.mcp
- api/agentscope.embedding
- api/agentscope.evaluate
- api/agentscope.plan
- api/agentscope.rag
- api/agentscope.token
- api/agentscope.tracing
- api/agentscope.session
- api/agentscope.exception
- api/agentscope.tts
diff --git a/docs/tutorial/en/src/task_eval_openjudge.py b/docs/tutorial/en/src/task_eval_openjudge.py
index afe040242..704e1ccae 100644
--- a/docs/tutorial/en/src/task_eval_openjudge.py
+++ b/docs/tutorial/en/src/task_eval_openjudge.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
"""
Evaluation with OpenJudge
=========================
@@ -16,7 +17,7 @@ OpenJudge is a comprehensive evaluation system designed to assess the quality of
Overview
--------
-While AgentScope provides a robust `MetricBase` for defining evaluation logic, implementing complex, semantic-level metrics (like "Hallucination Detection" or "Response Relevance") often requires
+While AgentScope provides a robust `MetricBase` for defining evaluation logic, implementing complex, semantic-level metrics (like "Hallucination Detection" or "Response Relevance") often requires
significant effort in prompt engineering and pipeline construction.
Integrating OpenJudge brings three dimensions of capability extension to AgentScope:
@@ -69,12 +70,12 @@ QA_BENCHMARK_DATASET = [
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# To make OpenJudge compatible with AgentScope, we need an adapter that inherits from
# AgentScope's ``MetricBase`` and acts as a bridge to OpenJudge's ``BaseGrader``.
-#
+#
# * **AgentScope Metric**: A generic unit of evaluation that accepts a ``SolutionOutput`` and returns a ``MetricResult``.
# * **OpenJudge Grader**: A specialized evaluation unit (e.g., ``RelevanceGrader``) that requires specific, semantic inputs (like ``query``, ``response``, ``context``), and returns a ``GraderResult``.
-#
+#
# This "Adapter" allows you to plug *any* OpenJudge grader into your AgentScope benchmark seamlessly.
-#
+#
# %%
from openjudge.graders.base_grader import BaseGrader
@@ -84,9 +85,10 @@ from agentscope.evaluate import (
MetricBase,
MetricType,
MetricResult,
- SolutionOutput
+ SolutionOutput,
)
+
class OpenJudgeMetric(MetricBase):
"""
A wrapper that converts an OpenJudge grader into an AgentScope Metric.
@@ -117,7 +119,9 @@ class OpenJudgeMetric(MetricBase):
"""Execute the wrapped OpenJudge grader against the agent solution."""
if not solution.success:
return MetricResult(
- name=self.name, result=0.0, message="Solution failed"
+ name=self.name,
+ result=0.0,
+ message="Solution failed",
)
try:
@@ -135,7 +139,8 @@ class OpenJudgeMetric(MetricBase):
# 2. Data Mapping
# Use the mapper to extract 'query', 'response', 'context' from the combined data
grader_inputs = parse_data_with_mapper(
- combined_data, self.mapper
+ combined_data,
+ self.mapper,
)
# 3. Evaluation Execution
@@ -164,7 +169,9 @@ class OpenJudgeMetric(MetricBase):
except Exception as e:
return MetricResult(
- name=self.name, result=0.0, message=f"Exception: {str(e)}"
+ name=self.name,
+ result=0.0,
+ message=f"Exception: {str(e)}",
)
@@ -173,15 +180,15 @@ class OpenJudgeMetric(MetricBase):
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# OpenJudge provides a rich collection of built-in graders. In this example, we select two
# common graders suitable for Question-Answering tasks:
-#
+#
# * **RelevanceGrader**: Evaluates whether the agent's response directly addresses the user's query.
# * **CorrectnessGrader**: Verifies the factual accuracy of the response against a provided ground truth.
-#
+#
# .. tip::
# OpenJudge offers 50+ built-in graders covering diverse dimensions like **Hallucination**, **Safety**, **Code Quality**,
# and **JSON Formatting**. Please refer to the `OpenJudge Documentation <https://agentscope-ai.github.io/OpenJudge/built_in_graders/overview/>`_
# for the full list of available graders.
-#
+#
# .. note::
# Ensure you have set your ``DASHSCOPE_API_KEY`` environment variable before running the example below.
@@ -201,7 +208,8 @@ class QABenchmark(BenchmarkBase):
def __init__(self):
super().__init__(
- name="QA Quality Benchmark", description="Benchmark to evaluate QA systems using OpenJudge grader classes"
+ name="QA Quality Benchmark",
+ description="Benchmark to evaluate QA systems using OpenJudge grader classes",
)
self.dataset = self._load_data()
@@ -212,7 +220,7 @@ class QABenchmark(BenchmarkBase):
model_config = {
"model": "qwen3-32b",
"api_key": os.environ.get("DASHSCOPE_API_KEY"),
- "base_url": "https://dashscope.aliyuncs.com/compatible-mode/v1"
+ "base_url": "https://dashscope.aliyuncs.com/compatible-mode/v1",
}
for data in QA_BENCHMARK_DATASET:
@@ -253,7 +261,7 @@ class QABenchmark(BenchmarkBase):
tasks.append(task)
return tasks
-
+
def __iter__(self) -> Generator[Task, None, None]:
"""Iterate over the benchmark."""
yield from self.dataset
@@ -266,6 +274,7 @@ class QABenchmark(BenchmarkBase):
"""Get the length of the benchmark."""
return len(self.dataset)
+
# %% [markdown]
# Run Evaluation
# ~~~~~~~~~~
@@ -275,15 +284,14 @@ class QABenchmark(BenchmarkBase):
# %%
-import asyncio
from typing import Callable
-from agentscope.agent._react_agent import ReActAgent
-from agentscope.evaluate._evaluator._general_evaluator import GeneralEvaluator
-from agentscope.evaluate._evaluator_storage._file_evaluator_storage import FileEvaluatorStorage
-from agentscope.formatter._dashscope_formatter import DashScopeChatFormatter
-from agentscope.message._message_base import Msg
-from agentscope.model._openai_model import OpenAIChatModel
+from agentscope.agent import ReActAgent
+from agentscope.evaluate import GeneralEvaluator
+from agentscope.evaluate import FileEvaluatorStorage
+from agentscope.formatter import DashScopeChatFormatter
+from agentscope.message import Msg
+from agentscope.model import OpenAIChatModel
async def qa_agent(task: Task, pre_hook: Callable) -> SolutionOutput:
@@ -291,7 +299,7 @@ async def qa_agent(task: Task, pre_hook: Callable) -> SolutionOutput:
model = OpenAIChatModel(
model_name="qwen3-32b",
- api_key=os.getenv("DASHSCOPE_API_KEY")
+ api_key=os.getenv("DASHSCOPE_API_KEY"),
)
# Create a QA agent
@@ -308,11 +316,16 @@ async def qa_agent(task: Task, pre_hook: Callable) -> SolutionOutput:
response_text = response.content
return SolutionOutput(
- success=True, output=response_text, trajectory=[task.input, response_text] # Store the interaction trajectory
+ success=True,
+ output=response_text,
+ trajectory=[
+ task.input,
+ response_text,
+ ], # Store the interaction trajectory
)
-async def main() -> None:
+async def main() -> None:
evaluator = GeneralEvaluator(
name="OpenJudge Integration Demo",
benchmark=QABenchmark(),
@@ -326,7 +339,3 @@ async def main() -> None:
)
await evaluator.run(qa_agent)
-
-asyncio.run(main())
-
-
diff --git a/docs/tutorial/en/src/task_realtime.py b/docs/tutorial/en/src/task_realtime.py
index 318dbebda..9f98077d1 100644
--- a/docs/tutorial/en/src/task_realtime.py
+++ b/docs/tutorial/en/src/task_realtime.py
@@ -62,32 +62,32 @@ from agentscope.realtime import (
#
#
# Here are examples of initializing different realtime models:
-
-# DashScope realtime model
-dashscope_model = DashScopeRealtimeModel(
- model_name="qwen3-omni-flash-realtime",
- api_key=os.getenv("DASHSCOPE_API_KEY"),
- voice="Cherry", # Options: "Cherry", "Serena", "Ethan", "Chelsie"
- enable_input_audio_transcription=True,
-)
-
-# OpenAI realtime model
-openai_model = OpenAIRealtimeModel(
- model_name="gpt-4o-realtime-preview",
- api_key=os.getenv("OPENAI_API_KEY"),
- voice="alloy", # Options: "alloy", "echo", "marin", "cedar"
- enable_input_audio_transcription=True,
-)
-
-# Gemini realtime model
-gemini_model = GeminiRealtimeModel(
- model_name="gemini-2.5-flash-native-audio-preview-09-2025",
- api_key=os.getenv("GEMINI_API_KEY"),
- voice="Puck", # Options: "Puck", "Charon", "Kore", "Fenrir"
- enable_input_audio_transcription=True,
-)
-
-# %%
+#
+# .. code-block:: python
+# :caption: Example of initializing different realtime models
+# # DashScope realtime model
+# dashscope_model = DashScopeRealtimeModel(
+# model_name="qwen3-omni-flash-realtime",
+# api_key=os.getenv("DASHSCOPE_API_KEY"),
+# voice="Cherry", # Options: "Cherry", "Serena", "Ethan", "Chelsie"
+# enable_input_audio_transcription=True,
+# )
+#
+# # OpenAI realtime model
+# openai_model = OpenAIRealtimeModel(
+# model_name="gpt-4o-realtime-preview",
+# api_key=os.getenv("OPENAI_API_KEY"),
+# voice="alloy", # Options: "alloy", "echo", "marin", "cedar"
+# enable_input_audio_transcription=True,
+# )
+#
+# # Gemini realtime model
+# gemini_model = GeminiRealtimeModel(
+# model_name="gemini-2.5-flash-native-audio-preview-09-2025",
+# api_key=os.getenv("GEMINI_API_KEY"),
+# voice="Puck", # Options: "Puck", "Charon", "Kore", "Fenrir"
+# enable_input_audio_transcription=True,
+# )
#
# The realtime model provides the following key methods:
#
@@ -483,7 +483,7 @@ async def example_chat_room() -> None:
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# The realtime agent feature is currently experimental and under active
-# development. Future plans include:
+# development. The future plans include:
#
# - Support for more realtime model APIs
# - Enhanced memory management for conversation history
diff --git a/docs/tutorial/zh_CN/build.sh b/docs/tutorial/zh_CN/build.sh
index 0fae4fc91..1a658d153 100755
--- a/docs/tutorial/zh_CN/build.sh
+++ b/docs/tutorial/zh_CN/build.sh
@@ -5,9 +5,6 @@ set -e
# Clean old build files
rm -rf build/ doctrees/
-# Generate the API rst files
-sphinx-apidoc -o api ../../../src/agentscope -t ../_templates -e
-
# Build the html
sphinx-build -M html ./ build
diff --git a/docs/tutorial/zh_CN/index.rst b/docs/tutorial/zh_CN/index.rst
index 22ae25a5a..b1e642524 100644
--- a/docs/tutorial/zh_CN/index.rst
+++ b/docs/tutorial/zh_CN/index.rst
@@ -74,27 +74,3 @@ Welcome to AgentScope's documentation!
tutorial/task_embedding
tutorial/task_tts
tutorial/task_tuner
-
-.. toctree::
- :maxdepth: 1
- :caption: API Docs
-
- api/agentscope
- api/agentscope.message
- api/agentscope.model
- api/agentscope.formatter
- api/agentscope.module
- api/agentscope.pipeline
- api/agentscope.agent
- api/agentscope.memory
- api/agentscope.tool
- api/agentscope.mcp
- api/agentscope.embedding
- api/agentscope.evaluate
- api/agentscope.plan
- api/agentscope.rag
- api/agentscope.token
- api/agentscope.tracing
- api/agentscope.session
- api/agentscope.exception
- api/agentscope.tts
diff --git a/docs/tutorial/zh_CN/src/task_eval_openjudge.py b/docs/tutorial/zh_CN/src/task_eval_openjudge.py
index 849b975ac..07a5389d2 100644
--- a/docs/tutorial/zh_CN/src/task_eval_openjudge.py
+++ b/docs/tutorial/zh_CN/src/task_eval_openjudge.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
"""
OpenJudge 评估器
=======================
@@ -81,7 +82,7 @@ from agentscope.evaluate import (
MetricBase,
MetricType,
MetricResult,
- SolutionOutput
+ SolutionOutput,
)
@@ -127,7 +128,9 @@ class OpenJudgeMetric(MetricBase):
"""针对 Agent 的输出执行封装好的 OpenJudge Grader。"""
if not solution.success:
return MetricResult(
- name=self.name, result=0.0, message="Solution failed"
+ name=self.name,
+ result=0.0,
+ message="Solution failed",
)
try:
@@ -145,7 +148,8 @@ class OpenJudgeMetric(MetricBase):
# 2. 数据映射
# 使用 mapper 从组合数据中提取Grader需要的 'query', 'response', 'context' 等参数
grader_inputs = parse_data_with_mapper(
- combined_data, self.mapper
+ combined_data,
+ self.mapper,
)
## 3. 执行评估
@@ -174,7 +178,9 @@ class OpenJudgeMetric(MetricBase):
except Exception as e:
return MetricResult(
- name=self.name, result=0.0, message=f"Exception: {str(e)}"
+ name=self.name,
+ result=0.0,
+ message=f"Exception: {str(e)}",
)
@@ -207,7 +213,8 @@ from agentscope.evaluate import (
class QABenchmark(BenchmarkBase):
def __init__(self):
super().__init__(
- name="QA Quality Benchmark", description="Benchmark to evaluate QA systems using OpenJudge grader classes"
+ name="QA Quality Benchmark",
+ description="Benchmark to evaluate QA systems using OpenJudge grader classes",
)
self.dataset = self._load_data()
@@ -218,7 +225,7 @@ class QABenchmark(BenchmarkBase):
model_config = {
"model": "qwen3-32b",
"api_key": os.environ.get("DASHSCOPE_API_KEY"),
- "base_url": "https://dashscope.aliyuncs.com/compatible-mode/v1"
+ "base_url": "https://dashscope.aliyuncs.com/compatible-mode/v1",
}
for data in QA_BENCHMARK_DATASET:
@@ -259,7 +266,7 @@ class QABenchmark(BenchmarkBase):
tasks.append(task)
return tasks
-
+
def __iter__(self) -> Generator[Task, None, None]:
yield from self.dataset
@@ -269,6 +276,7 @@ class QABenchmark(BenchmarkBase):
def __len__(self) -> int:
return len(self.dataset)
+
# %% [markdown]
# 运行评估
# ~~~~~~~~~~
@@ -280,19 +288,18 @@ class QABenchmark(BenchmarkBase):
import asyncio
from typing import Callable
-from agentscope.agent._react_agent import ReActAgent
-from agentscope.evaluate._evaluator._general_evaluator import GeneralEvaluator
-from agentscope.evaluate._evaluator_storage._file_evaluator_storage import FileEvaluatorStorage
-from agentscope.formatter._dashscope_formatter import DashScopeChatFormatter
-from agentscope.message._message_base import Msg
-from agentscope.model._openai_model import OpenAIChatModel
+from agentscope.agent import ReActAgent
+from agentscope.evaluate import GeneralEvaluator
+from agentscope.evaluate import FileEvaluatorStorage
+from agentscope.formatter import DashScopeChatFormatter
+from agentscope.message import Msg
+from agentscope.model import OpenAIChatModel
async def qa_agent(task: Task, pre_hook: Callable) -> SolutionOutput:
-
model = OpenAIChatModel(
model_name="qwen3-32b",
- api_key=os.getenv("DASHSCOPE_API_KEY")
+ api_key=os.getenv("DASHSCOPE_API_KEY"),
)
agent = ReActAgent(
name="QAAgent",
@@ -307,11 +314,16 @@ async def qa_agent(task: Task, pre_hook: Callable) -> SolutionOutput:
response_text = response.content
return SolutionOutput(
- success=True, output=response_text, trajectory=[task.input, response_text] # Store the interaction trajectory
+ success=True,
+ output=response_text,
+ trajectory=[
+ task.input,
+ response_text,
+ ], # Store the interaction trajectory
)
-async def main() -> None:
+async def main() -> None:
evaluator = GeneralEvaluator(
name="OpenJudge Integration Demo",
benchmark=QABenchmark(),
@@ -326,10 +338,11 @@ async def main() -> None:
await evaluator.run(qa_agent)
+
asyncio.run(main())
# %% [markdown]
-#
+#
# ~~~~~~~~~~
# 最后,使用 AgentScope 的 ``GeneralEvaluator`` 对一个简单的QA Agent进行评估测试。
# 我们将收集到来自 OpenJudge Grader 的 **量化分数 (Score)** 和 **定性理由 (Reasoning)**。
diff --git a/docs/tutorial/zh_CN/src/task_realtime.py b/docs/tutorial/zh_CN/src/task_realtime.py
index ca1384c3a..7d113bb03 100644
--- a/docs/tutorial/zh_CN/src/task_realtime.py
+++ b/docs/tutorial/zh_CN/src/task_realtime.py
@@ -59,32 +59,35 @@ from agentscope.realtime import (
#
#
# 以下是初始化不同实时模型的示例:
-
-# DashScope 实时模型
-dashscope_model = DashScopeRealtimeModel(
- model_name="qwen3-omni-flash-realtime",
- api_key=os.getenv("DASHSCOPE_API_KEY"),
- voice="Cherry", # 可选项: "Cherry", "Serena", "Ethan", "Chelsie"
- enable_input_audio_transcription=True,
-)
-
-# OpenAI 实时模型
-openai_model = OpenAIRealtimeModel(
- model_name="gpt-4o-realtime-preview",
- api_key=os.getenv("OPENAI_API_KEY"),
- voice="alloy", # 可选项: "alloy", "echo", "marin", "cedar"
- enable_input_audio_transcription=True,
-)
-
-# Gemini 实时模型
-gemini_model = GeminiRealtimeModel(
- model_name="gemini-2.5-flash-native-audio-preview-09-2025",
- api_key=os.getenv("GEMINI_API_KEY"),
- voice="Puck", # 可选项: "Puck", "Charon", "Kore", "Fenrir"
- enable_input_audio_transcription=True,
-)
-
-# %%
+#
+# .. code-block:: python
+# :caption: 初始化不同实时模型的示例
+#
+# # DashScope 实时模型
+# dashscope_model = DashScopeRealtimeModel(
+# model_name="qwen3-omni-flash-realtime",
+# api_key=os.getenv("DASHSCOPE_API_KEY"),
+# voice="Cherry", # 可选项: "Cherry", "Serena", "Ethan", "Chelsie"
+# enable_input_audio_transcription=True,
+# )
+#
+# # OpenAI 实时模型
+# openai_model = OpenAIRealtimeModel(
+# model_name="gpt-4o-realtime-preview",
+# api_key=os.getenv("OPENAI_API_KEY"),
+# voice="alloy", # 可选项: "alloy", "echo", "marin", "cedar"
+# enable_input_audio_transcription=True,
+# )
+#
+# # Gemini 实时模型
+# gemini_model = GeminiRealtimeModel(
+# model_name="gemini-2.5-flash-native-audio-preview-09-2025",
+# api_key=os.getenv("GEMINI_API_KEY"),
+# voice="Puck", # 可选项: "Puck", "Charon", "Kore", "Fenrir"
+# enable_input_audio_transcription=True,
+# )
+#
+#
#
# 实时模型提供以下核心方法:
#
diff --git a/pyproject.toml b/pyproject.toml
index 0ac39f771..bc2a95898 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -165,6 +165,8 @@ dev = [
"fakeredis",
"aiosqlite",
"greenlet",
+ # For openjudge
+ "py-openjudge",
]
[project.urls]
diff --git a/src/agentscope/realtime/_dashscope_realtime_model.py b/src/agentscope/realtime/_dashscope_realtime_model.py
index f319b7b44..09d374ce5 100644
--- a/src/agentscope/realtime/_dashscope_realtime_model.py
+++ b/src/agentscope/realtime/_dashscope_realtime_model.py
@@ -32,10 +32,7 @@ class DashScopeRealtimeModel(RealtimeModelBase):
)
"""The websocket URL of the DashScope realtime model API."""
- websocket_headers: dict[str, str] = {
- "Authorization": "Bearer {api_key}",
- "X-DashScope-DataInspection": "disable",
- }
+ websocket_headers: dict[str, str]
"""The websocket headers of the DashScope realtime model API."""
input_sample_rate: int
@@ -88,9 +85,10 @@ class DashScopeRealtimeModel(RealtimeModelBase):
self.websocket_url = self.websocket_url.format(model_name=model_name)
# Set the API key in the websocket headers.
- self.websocket_headers["Authorization"] = self.websocket_headers[
- "Authorization"
- ].format(api_key=api_key)
+ self.websocket_headers = {
+ "Authorization": f"Bearer {api_key}",
+ "X-DashScope-DataInspection": "disable",
+ }
# Record the response ID for the current session.
self._response_id = ""
diff --git a/src/agentscope/realtime/_gemini_realtime_model.py b/src/agentscope/realtime/_gemini_realtime_model.py
index b396cdbcb..52d194993 100644
--- a/src/agentscope/realtime/_gemini_realtime_model.py
+++ b/src/agentscope/realtime/_gemini_realtime_model.py
@@ -32,7 +32,7 @@ class GeminiRealtimeModel(RealtimeModelBase):
websocket_url: str = (
"wss://generativelanguage.googleapis.com/ws/"
"google.ai.generativelanguage.v1alpha.GenerativeService."
- "BidiGenerateContent?key={api_key}"
+ "BidiGenerateContent?key="
)
"""The websocket URL of the Gemini realtime model API."""
@@ -82,7 +82,7 @@ class GeminiRealtimeModel(RealtimeModelBase):
self.output_sample_rate = 24000
# Set the API key in the websocket URL.
- self.websocket_url = self.websocket_url.format(api_key=api_key)
+ self.websocket_url = self.websocket_url + api_key
# Response tracking state.
# Note: Unlike DashScope/OpenAI which send explicit `response.created`
diff --git a/src/agentscope/realtime/_openai_realtime_model.py b/src/agentscope/realtime/_openai_realtime_model.py
index e75a4fa27..355727566 100644
--- a/src/agentscope/realtime/_openai_realtime_model.py
+++ b/src/agentscope/realtime/_openai_realtime_model.py
@@ -28,10 +28,7 @@ class OpenAIRealtimeModel(RealtimeModelBase):
websocket_url: str = "wss://api.openai.com/v1/realtime?model={model_name}"
"""The websocket URL of the OpenAI realtime model API."""
- websocket_headers: dict[str, str] = {
- "Authorization": "Bearer {api_key}",
- "OpenAI-Beta": "realtime=v1",
- }
+ websocket_headers: dict[str, str]
"""The websocket headers of the OpenAI realtime model API."""
input_sample_rate: int
@@ -75,9 +72,10 @@ class OpenAIRealtimeModel(RealtimeModelBase):
self.websocket_url = self.websocket_url.format(model_name=model_name)
# Set the API key in the websocket headers.
- self.websocket_headers["Authorization"] = self.websocket_headers[
- "Authorization"
- ].format(api_key=api_key)
+ self.websocket_headers = {
+ "Authorization": f"Bearer {api_key}",
+ "OpenAI-Beta": "realtime=v1",
+ }
# Record the response ID for the current session.
self._response_id = ""
diff --git a/tests/rag_knowledge_test.py b/tests/rag_knowledge_test.py
index a1f3e8ee0..55611236b 100644
--- a/tests/rag_knowledge_test.py
+++ b/tests/rag_knowledge_test.py
@@ -104,6 +104,6 @@ class RAGKnowledgeTest(IsolatedAsyncioTestCase):
"This is an apple.",
)
self.assertEqual(
- res[0].score,
- 0.9974149072579597,
+ res[0].score // 0.0001,
+ 9974,
)
diff --git a/tests/rag_store_test.py b/tests/rag_store_test.py
index 72e53ad69..954e1abcd 100644
--- a/tests/rag_store_test.py
+++ b/tests/rag_store_test.py
@@ -72,8 +72,8 @@ class RAGStoreTest(IsolatedAsyncioTestCase):
)
self.assertEqual(len(res), 1)
self.assertEqual(
- res[0].score,
- 0.9974149072579597,
+ res[0].score // 0.0001,
+ 9974,
)
self.assertEqual(
res[0].metadata.content["text"],