TGStat
TGStat
Type to search
Advanced channel search
  • flag English
    Site language
    flag Russian flag English flag Uzbek
  • Sign In
  • Catalog
    Channels and groups catalog Search for channels
    Add a channel/group
  • Ratings
    Rating of channels Rating of groups Posts rating
    Ratings of brands and people
  • Analytics
  • Search by posts
  • Telegram monitoring
Исаев Василий - заметки про it, python и ai

5 May, 16:01

Open in Telegram Share Report

#нейрохрючево
системник

### No hasattr()
# ❌
if hasattr(obj, "model"):
model = obj.model


КОДИК:
def from_litellm(cls, response: Union[ModelResponse, ResponsesAPIResponse]) -> 'LLMResponse':
if isinstance(response, ResponsesAPIResponse):
model = response.model
content = ""
structured_data = None

# Extract content from output
if response.output:
for item in response.output:
if hasattr(item, 'type') and item.type == 'message':
# item is usually a ChatCompletionAssistantMessageParam-like object
# or a dict if it was dumped.
if hasattr(item, 'content'):
if isinstance(item.content, list):
for part in item.content:
if hasattr(part, 'type') and part.type == 'output_text':
content += part.text
elif isinstance(part, dict) and part.get('type') == 'output_text':
content += part.get('text', '')
elif isinstance(item.content, str):
content += item.content
elif isinstance(item, dict) and 'content' in item:
if isinstance(item['content'], list):
for part in item['content']:
if part.get('type') == 'output_text':
content += part.get('text', '')
elif isinstance(item['content'], str):
content += item['content']

215 0 1 3
Catalog
Channels and groups catalog Channels compilations Search for channels Add a channel/group
Ratings
Rating of Telegram channels Rating of Telegram groups Posts rating Ratings of brands and people
API
API statistics Search API of posts API Callback
Our channels
@TGStat @TGStat_Chat @telepulse @TGStatAPI
Read
Академия TGStat Telegram Research 2019 Telegram Research 2021 Telegram Research 2023
Contacts
Справочный центр Support Email Jobs
Miscellaneous
Terms and conditions Privacy policy Public offer
Our bots
@TGStat_Bot @SearcheeBot @TGAlertsBot @tg_analytics_bot @TGStatChatBot