Skip to content

Commit

Permalink
resoving problems
Browse files Browse the repository at this point in the history
  • Loading branch information
garyzhang99 committed May 1, 2024
1 parent 93c3e91 commit 83bedfe
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion docs/sphinx_doc/en/source/tutorial/203-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ Here we provide example configurations for different model wrappers.
"model_name": "{model_name}", # The model name in ZhipuAI API, e.g. embedding-2

# Optional parameters
"api_key": "{your_api_key}", #
"api_key": "{your_api_key}",
}
```

Expand Down
1 change: 0 additions & 1 deletion docs/sphinx_doc/en/source/tutorial/206-prompt.md
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,6 @@ print(prompt)
- Require `role` and `content` fields, and `role` must be either `"user"`
`"system"` or `"assistant"`.
- There must be at least one `user` message.
- The `user` must speak in the beginning and end of the input messages list.

#### Prompt Strategy

Expand Down
2 changes: 1 addition & 1 deletion docs/sphinx_doc/zh_CN/source/tutorial/203-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ API如下:
"model_name": "{model_name}", # The model name in ZhipuAI API, e.g. embedding-2

# Optional parameters
"api_key": "{your_api_key}", #
"api_key": "{your_api_key}",
}
```

Expand Down
15 changes: 5 additions & 10 deletions src/agentscope/models/zhipu_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def __init__(

self.client = zhipuai.ZhipuAI(
api_key=api_key,
**kwargs,
)

self._register_default_metrics()
Expand Down Expand Up @@ -316,16 +317,10 @@ def __call__(

# step5: return response
response_json = response.model_dump()
if len(response_json["data"]) == 0:
return ModelResponse(
embedding=response_json["data"]["embedding"][0],
raw=response_json,
)
else:
return ModelResponse(
embedding=[_["embedding"] for _ in response_json["data"]],
raw=response_json,
)
return ModelResponse(
embedding=[_["embedding"] for _ in response_json["data"]],
raw=response_json,
)

def _register_default_metrics(self) -> None:
# Set monitor accordingly
Expand Down
2 changes: 1 addition & 1 deletion tests/format_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def test_dashscope_chat(self) -> None:
model.format(*self.wrong_inputs) # type: ignore[arg-type]

def test_zhipuai_chat(self) -> None:
"""Unit test for the format function in dashscope chat api wrapper."""
"""Unit test for the format function in zhipu chat api wrapper."""
model = ZhipuAIChatWrapper(
config_name="",
model_name="glm-4",
Expand Down

0 comments on commit 83bedfe

Please sign in to comment.