"NoneType' object has no attribute 'cost" #4999
Unanswered
Brutal15229
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
`import json
import requests
from requests.auth import HTTPBasicAuth
from requests_cache import CachedSession
from types import SimpleNamespace
from dotenv import dotenv_values
Load environment variables
env_vars = dotenv_values('.env')
Configure cached session
session = CachedSession(
cache_name='cache/BearerToken',
expire_after=3600 # Cache expiry time in seconds
)
class CustomModelClient:
def init(self, config, **kwargs):
self.config = config
print(f"CustomModelClient config: {config}")
# Authentication URL and other relevant parameters
self.auth_url = env_vars.get('AUTH_URL')
self.username = env_vars.get('USERNAME')
self.password = env_vars.get('PASSWORD')
self.api_url = env_vars.get('OPENAI_API_URL')
self.subscription_key = env_vars.get('OCP-APIM-SUBSCRIPTION-KEY')
self.model="custom_llm_model"
`groupchat_1 = autogen.GroupChat(agents=[user_proxy_new_1, demand_forecaster_agent_updated_1,inventory_optimizer_updated_1], messages=[], max_round=6,speaker_selection_method=state_transition,)
manager_1 = autogen.GroupChatManager(groupchat=groupchat_1, llm_config=llm_custom_config,is_termination_msg=lambda x: x.get("content", "") and x.get("content", "").rstrip().endswith("TERMINATE"),code_execution_config=False,)
this is my CustomModelClient Code
file_path = r'retail_store_inventory.csv'
Start the conversation
user_proxy_new_1.initiate_chat(manager_1, message=f"load the data from {file_path} and Store_id = S002 and Region is West also provide me the recommendations or suggestions for what i should do in case of inventory optimization")
it is able to call the First agent and is able to show the output however when it is going to second agent it is showing
...
def cost(response):
-->response.cost = 0 # Placeholder for actual cost logic
return 0
AttributeError: 'NoneType' object has no attribute 'cost'
Why it is happening and what should i do to remove this error.
Beta Was this translation helpful? Give feedback.
All reactions