Skip to content

armgit / camel

Public Imported from GitHub
0

🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org

chore: polish PR 1236 (#1248)

Wendong-Fan8e4602c1f141
diff --git a/camel/agents/chat_agent.py b/camel/agents/chat_agent.py
index fdeeb779b..c26add253 100644
--- a/camel/agents/chat_agent.py
+++ b/camel/agents/chat_agent.py
@@ -1091,9 +1091,12 @@ class ChatAgent(BaseAgent):
meta_dict=dict(),
content=choice.message.content or "",
)
+ # Process log probabilities and append to the message meta information
if choice.logprobs is not None:
tokens_logprobs = choice.logprobs.content
+
if tokens_logprobs is not None:
+ # Extract and structure logprob information
logprobs_info = [
{
"token": token_logprob.token,
@@ -1105,9 +1108,11 @@ class ChatAgent(BaseAgent):
}
for token_logprob in tokens_logprobs
]
+ # Ensure meta_dict exists before adding logprobs info
if chat_message.meta_dict is None:
chat_message.meta_dict = {}
chat_message.meta_dict["logprobs_info"] = logprobs_info
+ # Append the processed chat message to output
output_messages.append(chat_message)
finish_reasons = [
diff --git a/camel/configs/vllm_config.py b/camel/configs/vllm_config.py
index e3439f83b..b3d8fb842 100644
--- a/camel/configs/vllm_config.py
+++ b/camel/configs/vllm_config.py
@@ -84,12 +84,13 @@ class VLLMConfig(BaseConfig):
user (str, optional): A unique identifier representing your end-user,
which can help OpenAI to monitor and detect abuse.
(default: :obj:`""`)
- logprobs: Whether to return log probabilities of the output tokens or not. If true,
- returns the log probabilities of each output token returned in the `logits` of
- `message`.
- top_logprobs: An integer between 0 and 20 specifying the number of most likely tokens to
- return at each token position, each with an associated log probability.
- `logprobs` must be set to `true` if this parameter is used.
+ logprobs: Whether to return log probabilities of the output tokens or
+ not. If true, returns the log probabilities of each output token
+ returned in the `logits` of `message`. (default: :obj:`None`)
+ top_logprobs: An integer between 0 and 20 specifying the number of
+ most likely tokens to return at each token position, each with an
+ associated log probability. `logprobs` must be set to `true` if
+ this parameter is used. (default: :obj:`None`)
"""
temperature: float = 0.2 # openai default: 1.0
diff --git a/camel/responses/agent_responses.py b/camel/responses/agent_responses.py
index 78320331d..3fa960f0f 100644
--- a/camel/responses/agent_responses.py
+++ b/camel/responses/agent_responses.py
@@ -44,26 +44,3 @@ class ChatAgentResponse(BaseModel):
"for a single message in msgs."
)
return self.msgs[0]
-
- @property
- def logits(self):
- """Return the logits associated with the first message in msgs.
-
- This property retrieves the `meta_dict` of the first message in `msgs`,
- which contains information such as token log probabilities and top log
- probabilities that were computed during message generation.
-
- Returns:
- dict: A dictionary containing the logits or log probability
- information of the tokens.
-
- Raises:
- RuntimeError: If the list of messages (`msgs`) does not contain
- exactly one message.
- """
- if len(self.msgs) != 1:
- raise RuntimeError(
- "Property msg is only available "
- "for a single message in msgs."
- )
- return self.msgs[0].meta_dict