ag2 0.4.1__py3-none-any.whl → 0.4.2b1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ag2 might be problematic. Click here for more details.
- ag2-0.4.2b1.dist-info/METADATA +19 -0
- ag2-0.4.2b1.dist-info/RECORD +6 -0
- ag2-0.4.2b1.dist-info/top_level.txt +1 -0
- ag2-0.4.1.dist-info/METADATA +0 -500
- ag2-0.4.1.dist-info/RECORD +0 -158
- ag2-0.4.1.dist-info/top_level.txt +0 -1
- autogen/__init__.py +0 -17
- autogen/_pydantic.py +0 -116
- autogen/agentchat/__init__.py +0 -42
- autogen/agentchat/agent.py +0 -142
- autogen/agentchat/assistant_agent.py +0 -85
- autogen/agentchat/chat.py +0 -306
- autogen/agentchat/contrib/__init__.py +0 -0
- autogen/agentchat/contrib/agent_builder.py +0 -788
- autogen/agentchat/contrib/agent_eval/agent_eval.py +0 -107
- autogen/agentchat/contrib/agent_eval/criterion.py +0 -47
- autogen/agentchat/contrib/agent_eval/critic_agent.py +0 -47
- autogen/agentchat/contrib/agent_eval/quantifier_agent.py +0 -42
- autogen/agentchat/contrib/agent_eval/subcritic_agent.py +0 -48
- autogen/agentchat/contrib/agent_eval/task.py +0 -43
- autogen/agentchat/contrib/agent_optimizer.py +0 -450
- autogen/agentchat/contrib/capabilities/__init__.py +0 -0
- autogen/agentchat/contrib/capabilities/agent_capability.py +0 -21
- autogen/agentchat/contrib/capabilities/generate_images.py +0 -297
- autogen/agentchat/contrib/capabilities/teachability.py +0 -406
- autogen/agentchat/contrib/capabilities/text_compressors.py +0 -72
- autogen/agentchat/contrib/capabilities/transform_messages.py +0 -92
- autogen/agentchat/contrib/capabilities/transforms.py +0 -565
- autogen/agentchat/contrib/capabilities/transforms_util.py +0 -120
- autogen/agentchat/contrib/capabilities/vision_capability.py +0 -217
- autogen/agentchat/contrib/captainagent/tools/__init__.py +0 -0
- autogen/agentchat/contrib/captainagent/tools/data_analysis/calculate_correlation.py +0 -41
- autogen/agentchat/contrib/captainagent/tools/data_analysis/calculate_skewness_and_kurtosis.py +0 -29
- autogen/agentchat/contrib/captainagent/tools/data_analysis/detect_outlier_iqr.py +0 -29
- autogen/agentchat/contrib/captainagent/tools/data_analysis/detect_outlier_zscore.py +0 -29
- autogen/agentchat/contrib/captainagent/tools/data_analysis/explore_csv.py +0 -22
- autogen/agentchat/contrib/captainagent/tools/data_analysis/shapiro_wilk_test.py +0 -31
- autogen/agentchat/contrib/captainagent/tools/information_retrieval/arxiv_download.py +0 -26
- autogen/agentchat/contrib/captainagent/tools/information_retrieval/arxiv_search.py +0 -55
- autogen/agentchat/contrib/captainagent/tools/information_retrieval/extract_pdf_image.py +0 -54
- autogen/agentchat/contrib/captainagent/tools/information_retrieval/extract_pdf_text.py +0 -39
- autogen/agentchat/contrib/captainagent/tools/information_retrieval/get_wikipedia_text.py +0 -22
- autogen/agentchat/contrib/captainagent/tools/information_retrieval/get_youtube_caption.py +0 -35
- autogen/agentchat/contrib/captainagent/tools/information_retrieval/image_qa.py +0 -61
- autogen/agentchat/contrib/captainagent/tools/information_retrieval/optical_character_recognition.py +0 -62
- autogen/agentchat/contrib/captainagent/tools/information_retrieval/perform_web_search.py +0 -48
- autogen/agentchat/contrib/captainagent/tools/information_retrieval/scrape_wikipedia_tables.py +0 -34
- autogen/agentchat/contrib/captainagent/tools/information_retrieval/transcribe_audio_file.py +0 -22
- autogen/agentchat/contrib/captainagent/tools/information_retrieval/youtube_download.py +0 -36
- autogen/agentchat/contrib/captainagent/tools/math/calculate_circle_area_from_diameter.py +0 -22
- autogen/agentchat/contrib/captainagent/tools/math/calculate_day_of_the_week.py +0 -19
- autogen/agentchat/contrib/captainagent/tools/math/calculate_fraction_sum.py +0 -29
- autogen/agentchat/contrib/captainagent/tools/math/calculate_matrix_power.py +0 -32
- autogen/agentchat/contrib/captainagent/tools/math/calculate_reflected_point.py +0 -17
- autogen/agentchat/contrib/captainagent/tools/math/complex_numbers_product.py +0 -26
- autogen/agentchat/contrib/captainagent/tools/math/compute_currency_conversion.py +0 -24
- autogen/agentchat/contrib/captainagent/tools/math/count_distinct_permutations.py +0 -28
- autogen/agentchat/contrib/captainagent/tools/math/evaluate_expression.py +0 -29
- autogen/agentchat/contrib/captainagent/tools/math/find_continuity_point.py +0 -35
- autogen/agentchat/contrib/captainagent/tools/math/fraction_to_mixed_numbers.py +0 -40
- autogen/agentchat/contrib/captainagent/tools/math/modular_inverse_sum.py +0 -23
- autogen/agentchat/contrib/captainagent/tools/math/simplify_mixed_numbers.py +0 -37
- autogen/agentchat/contrib/captainagent/tools/math/sum_of_digit_factorials.py +0 -16
- autogen/agentchat/contrib/captainagent/tools/math/sum_of_primes_below.py +0 -16
- autogen/agentchat/contrib/captainagent/tools/requirements.txt +0 -10
- autogen/agentchat/contrib/captainagent/tools/tool_description.tsv +0 -34
- autogen/agentchat/contrib/captainagent.py +0 -490
- autogen/agentchat/contrib/gpt_assistant_agent.py +0 -545
- autogen/agentchat/contrib/graph_rag/__init__.py +0 -0
- autogen/agentchat/contrib/graph_rag/document.py +0 -30
- autogen/agentchat/contrib/graph_rag/falkor_graph_query_engine.py +0 -111
- autogen/agentchat/contrib/graph_rag/falkor_graph_rag_capability.py +0 -81
- autogen/agentchat/contrib/graph_rag/graph_query_engine.py +0 -56
- autogen/agentchat/contrib/graph_rag/graph_rag_capability.py +0 -64
- autogen/agentchat/contrib/img_utils.py +0 -390
- autogen/agentchat/contrib/llamaindex_conversable_agent.py +0 -123
- autogen/agentchat/contrib/llava_agent.py +0 -176
- autogen/agentchat/contrib/math_user_proxy_agent.py +0 -471
- autogen/agentchat/contrib/multimodal_conversable_agent.py +0 -128
- autogen/agentchat/contrib/qdrant_retrieve_user_proxy_agent.py +0 -325
- autogen/agentchat/contrib/retrieve_assistant_agent.py +0 -56
- autogen/agentchat/contrib/retrieve_user_proxy_agent.py +0 -705
- autogen/agentchat/contrib/society_of_mind_agent.py +0 -203
- autogen/agentchat/contrib/swarm_agent.py +0 -463
- autogen/agentchat/contrib/text_analyzer_agent.py +0 -76
- autogen/agentchat/contrib/tool_retriever.py +0 -120
- autogen/agentchat/contrib/vectordb/__init__.py +0 -0
- autogen/agentchat/contrib/vectordb/base.py +0 -243
- autogen/agentchat/contrib/vectordb/chromadb.py +0 -326
- autogen/agentchat/contrib/vectordb/mongodb.py +0 -559
- autogen/agentchat/contrib/vectordb/pgvectordb.py +0 -958
- autogen/agentchat/contrib/vectordb/qdrant.py +0 -334
- autogen/agentchat/contrib/vectordb/utils.py +0 -126
- autogen/agentchat/contrib/web_surfer.py +0 -305
- autogen/agentchat/conversable_agent.py +0 -2908
- autogen/agentchat/groupchat.py +0 -1668
- autogen/agentchat/user_proxy_agent.py +0 -109
- autogen/agentchat/utils.py +0 -207
- autogen/browser_utils.py +0 -291
- autogen/cache/__init__.py +0 -10
- autogen/cache/abstract_cache_base.py +0 -78
- autogen/cache/cache.py +0 -182
- autogen/cache/cache_factory.py +0 -85
- autogen/cache/cosmos_db_cache.py +0 -150
- autogen/cache/disk_cache.py +0 -109
- autogen/cache/in_memory_cache.py +0 -61
- autogen/cache/redis_cache.py +0 -128
- autogen/code_utils.py +0 -745
- autogen/coding/__init__.py +0 -22
- autogen/coding/base.py +0 -113
- autogen/coding/docker_commandline_code_executor.py +0 -262
- autogen/coding/factory.py +0 -45
- autogen/coding/func_with_reqs.py +0 -203
- autogen/coding/jupyter/__init__.py +0 -22
- autogen/coding/jupyter/base.py +0 -32
- autogen/coding/jupyter/docker_jupyter_server.py +0 -164
- autogen/coding/jupyter/embedded_ipython_code_executor.py +0 -182
- autogen/coding/jupyter/jupyter_client.py +0 -224
- autogen/coding/jupyter/jupyter_code_executor.py +0 -161
- autogen/coding/jupyter/local_jupyter_server.py +0 -168
- autogen/coding/local_commandline_code_executor.py +0 -410
- autogen/coding/markdown_code_extractor.py +0 -44
- autogen/coding/utils.py +0 -57
- autogen/exception_utils.py +0 -46
- autogen/extensions/__init__.py +0 -0
- autogen/formatting_utils.py +0 -76
- autogen/function_utils.py +0 -362
- autogen/graph_utils.py +0 -148
- autogen/io/__init__.py +0 -15
- autogen/io/base.py +0 -105
- autogen/io/console.py +0 -43
- autogen/io/websockets.py +0 -213
- autogen/logger/__init__.py +0 -11
- autogen/logger/base_logger.py +0 -140
- autogen/logger/file_logger.py +0 -287
- autogen/logger/logger_factory.py +0 -29
- autogen/logger/logger_utils.py +0 -42
- autogen/logger/sqlite_logger.py +0 -459
- autogen/math_utils.py +0 -356
- autogen/oai/__init__.py +0 -33
- autogen/oai/anthropic.py +0 -428
- autogen/oai/bedrock.py +0 -606
- autogen/oai/cerebras.py +0 -270
- autogen/oai/client.py +0 -1148
- autogen/oai/client_utils.py +0 -167
- autogen/oai/cohere.py +0 -453
- autogen/oai/completion.py +0 -1216
- autogen/oai/gemini.py +0 -469
- autogen/oai/groq.py +0 -281
- autogen/oai/mistral.py +0 -279
- autogen/oai/ollama.py +0 -582
- autogen/oai/openai_utils.py +0 -811
- autogen/oai/together.py +0 -343
- autogen/retrieve_utils.py +0 -487
- autogen/runtime_logging.py +0 -163
- autogen/token_count_utils.py +0 -259
- autogen/types.py +0 -20
- autogen/version.py +0 -7
- {ag2-0.4.1.dist-info → ag2-0.4.2b1.dist-info}/LICENSE +0 -0
- {ag2-0.4.1.dist-info → ag2-0.4.2b1.dist-info}/NOTICE.md +0 -0
- {ag2-0.4.1.dist-info → ag2-0.4.2b1.dist-info}/WHEEL +0 -0
autogen/oai/together.py
DELETED
|
@@ -1,343 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2023 - 2024, Owners of https://github.com/ag2ai
|
|
2
|
-
#
|
|
3
|
-
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
#
|
|
5
|
-
# Portions derived from https://github.com/microsoft/autogen are under the MIT License.
|
|
6
|
-
# SPDX-License-Identifier: MIT
|
|
7
|
-
"""Create an OpenAI-compatible client using Together.AI's API.
|
|
8
|
-
|
|
9
|
-
Example:
|
|
10
|
-
llm_config={
|
|
11
|
-
"config_list": [{
|
|
12
|
-
"api_type": "together",
|
|
13
|
-
"model": "mistralai/Mixtral-8x7B-Instruct-v0.1",
|
|
14
|
-
"api_key": os.environ.get("TOGETHER_API_KEY")
|
|
15
|
-
}
|
|
16
|
-
]}
|
|
17
|
-
|
|
18
|
-
agent = autogen.AssistantAgent("my_agent", llm_config=llm_config)
|
|
19
|
-
|
|
20
|
-
Install Together.AI python library using: pip install --upgrade together
|
|
21
|
-
|
|
22
|
-
Resources:
|
|
23
|
-
- https://docs.together.ai/docs/inference-python
|
|
24
|
-
"""
|
|
25
|
-
|
|
26
|
-
from __future__ import annotations
|
|
27
|
-
|
|
28
|
-
import base64
|
|
29
|
-
import copy
|
|
30
|
-
import os
|
|
31
|
-
import random
|
|
32
|
-
import re
|
|
33
|
-
import time
|
|
34
|
-
import warnings
|
|
35
|
-
from io import BytesIO
|
|
36
|
-
from typing import Any, Dict, List, Mapping, Tuple, Union
|
|
37
|
-
|
|
38
|
-
import requests
|
|
39
|
-
from openai.types.chat import ChatCompletion, ChatCompletionMessageToolCall
|
|
40
|
-
from openai.types.chat.chat_completion import ChatCompletionMessage, Choice
|
|
41
|
-
from openai.types.completion_usage import CompletionUsage
|
|
42
|
-
from PIL import Image
|
|
43
|
-
from together import Together, error
|
|
44
|
-
|
|
45
|
-
from autogen.oai.client_utils import should_hide_tools, validate_parameter
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
class TogetherClient:
|
|
49
|
-
"""Client for Together.AI's API."""
|
|
50
|
-
|
|
51
|
-
def __init__(self, **kwargs):
|
|
52
|
-
"""Requires api_key or environment variable to be set
|
|
53
|
-
|
|
54
|
-
Args:
|
|
55
|
-
api_key (str): The API key for using Together.AI (or environment variable TOGETHER_API_KEY needs to be set)
|
|
56
|
-
"""
|
|
57
|
-
# Ensure we have the api_key upon instantiation
|
|
58
|
-
self.api_key = kwargs.get("api_key", None)
|
|
59
|
-
if not self.api_key:
|
|
60
|
-
self.api_key = os.getenv("TOGETHER_API_KEY")
|
|
61
|
-
|
|
62
|
-
assert (
|
|
63
|
-
self.api_key
|
|
64
|
-
), "Please include the api_key in your config list entry for Together.AI or set the TOGETHER_API_KEY env variable."
|
|
65
|
-
|
|
66
|
-
def message_retrieval(self, response) -> List:
|
|
67
|
-
"""
|
|
68
|
-
Retrieve and return a list of strings or a list of Choice.Message from the response.
|
|
69
|
-
|
|
70
|
-
NOTE: if a list of Choice.Message is returned, it currently needs to contain the fields of OpenAI's ChatCompletion Message object,
|
|
71
|
-
since that is expected for function or tool calling in the rest of the codebase at the moment, unless a custom agent is being used.
|
|
72
|
-
"""
|
|
73
|
-
return [choice.message for choice in response.choices]
|
|
74
|
-
|
|
75
|
-
def cost(self, response) -> float:
|
|
76
|
-
return response.cost
|
|
77
|
-
|
|
78
|
-
@staticmethod
|
|
79
|
-
def get_usage(response) -> Dict:
|
|
80
|
-
"""Return usage summary of the response using RESPONSE_USAGE_KEYS."""
|
|
81
|
-
# ... # pragma: no cover
|
|
82
|
-
return {
|
|
83
|
-
"prompt_tokens": response.usage.prompt_tokens,
|
|
84
|
-
"completion_tokens": response.usage.completion_tokens,
|
|
85
|
-
"total_tokens": response.usage.total_tokens,
|
|
86
|
-
"cost": response.cost,
|
|
87
|
-
"model": response.model,
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
def parse_params(self, params: Dict[str, Any]) -> Dict[str, Any]:
|
|
91
|
-
"""Loads the parameters for Together.AI API from the passed in parameters and returns a validated set. Checks types, ranges, and sets defaults"""
|
|
92
|
-
together_params = {}
|
|
93
|
-
|
|
94
|
-
# Check that we have what we need to use Together.AI's API
|
|
95
|
-
together_params["model"] = params.get("model", None)
|
|
96
|
-
assert together_params[
|
|
97
|
-
"model"
|
|
98
|
-
], "Please specify the 'model' in your config list entry to nominate the Together.AI model to use."
|
|
99
|
-
|
|
100
|
-
# Validate allowed Together.AI parameters
|
|
101
|
-
# https://github.com/togethercomputer/together-python/blob/94ffb30daf0ac3e078be986af7228f85f79bde99/src/together/resources/completions.py#L44
|
|
102
|
-
together_params["max_tokens"] = validate_parameter(params, "max_tokens", int, True, 512, (0, None), None)
|
|
103
|
-
together_params["stream"] = validate_parameter(params, "stream", bool, False, False, None, None)
|
|
104
|
-
together_params["temperature"] = validate_parameter(params, "temperature", (int, float), True, None, None, None)
|
|
105
|
-
together_params["top_p"] = validate_parameter(params, "top_p", (int, float), True, None, None, None)
|
|
106
|
-
together_params["top_k"] = validate_parameter(params, "top_k", int, True, None, None, None)
|
|
107
|
-
together_params["repetition_penalty"] = validate_parameter(
|
|
108
|
-
params, "repetition_penalty", float, True, None, None, None
|
|
109
|
-
)
|
|
110
|
-
together_params["presence_penalty"] = validate_parameter(
|
|
111
|
-
params, "presence_penalty", (int, float), True, None, (-2, 2), None
|
|
112
|
-
)
|
|
113
|
-
together_params["frequency_penalty"] = validate_parameter(
|
|
114
|
-
params, "frequency_penalty", (int, float), True, None, (-2, 2), None
|
|
115
|
-
)
|
|
116
|
-
together_params["min_p"] = validate_parameter(params, "min_p", (int, float), True, None, (0, 1), None)
|
|
117
|
-
together_params["safety_model"] = validate_parameter(
|
|
118
|
-
params, "safety_model", str, True, None, None, None
|
|
119
|
-
) # We won't enforce the available models as they are likely to change
|
|
120
|
-
|
|
121
|
-
# Check if they want to stream and use tools, which isn't currently supported (TODO)
|
|
122
|
-
if together_params["stream"] and "tools" in params:
|
|
123
|
-
warnings.warn(
|
|
124
|
-
"Streaming is not supported when using tools, streaming will be disabled.",
|
|
125
|
-
UserWarning,
|
|
126
|
-
)
|
|
127
|
-
|
|
128
|
-
together_params["stream"] = False
|
|
129
|
-
|
|
130
|
-
return together_params
|
|
131
|
-
|
|
132
|
-
def create(self, params: Dict) -> ChatCompletion:
|
|
133
|
-
|
|
134
|
-
messages = params.get("messages", [])
|
|
135
|
-
|
|
136
|
-
# Convert AutoGen messages to Together.AI messages
|
|
137
|
-
together_messages = oai_messages_to_together_messages(messages)
|
|
138
|
-
|
|
139
|
-
# Parse parameters to Together.AI API's parameters
|
|
140
|
-
together_params = self.parse_params(params)
|
|
141
|
-
|
|
142
|
-
# Add tools to the call if we have them and aren't hiding them
|
|
143
|
-
if "tools" in params:
|
|
144
|
-
hide_tools = validate_parameter(
|
|
145
|
-
params, "hide_tools", str, False, "never", None, ["if_all_run", "if_any_run", "never"]
|
|
146
|
-
)
|
|
147
|
-
if not should_hide_tools(together_messages, params["tools"], hide_tools):
|
|
148
|
-
together_params["tools"] = params["tools"]
|
|
149
|
-
|
|
150
|
-
together_params["messages"] = together_messages
|
|
151
|
-
|
|
152
|
-
# We use chat model by default
|
|
153
|
-
client = Together(api_key=self.api_key)
|
|
154
|
-
|
|
155
|
-
# Token counts will be returned
|
|
156
|
-
prompt_tokens = 0
|
|
157
|
-
completion_tokens = 0
|
|
158
|
-
total_tokens = 0
|
|
159
|
-
|
|
160
|
-
response = client.chat.completions.create(**together_params)
|
|
161
|
-
if together_params["stream"]:
|
|
162
|
-
# Read in the chunks as they stream
|
|
163
|
-
ans = ""
|
|
164
|
-
for chunk in response:
|
|
165
|
-
ans = ans + (chunk.choices[0].delta.content or "")
|
|
166
|
-
|
|
167
|
-
prompt_tokens = chunk.usage.prompt_tokens
|
|
168
|
-
completion_tokens = chunk.usage.completion_tokens
|
|
169
|
-
total_tokens = chunk.usage.total_tokens
|
|
170
|
-
else:
|
|
171
|
-
ans: str = response.choices[0].message.content
|
|
172
|
-
|
|
173
|
-
prompt_tokens = response.usage.prompt_tokens
|
|
174
|
-
completion_tokens = response.usage.completion_tokens
|
|
175
|
-
total_tokens = response.usage.total_tokens
|
|
176
|
-
|
|
177
|
-
if response.choices[0].finish_reason == "tool_calls":
|
|
178
|
-
together_finish = "tool_calls"
|
|
179
|
-
tool_calls = []
|
|
180
|
-
for tool_call in response.choices[0].message.tool_calls:
|
|
181
|
-
tool_calls.append(
|
|
182
|
-
ChatCompletionMessageToolCall(
|
|
183
|
-
id=tool_call.id,
|
|
184
|
-
function={"name": tool_call.function.name, "arguments": tool_call.function.arguments},
|
|
185
|
-
type="function",
|
|
186
|
-
)
|
|
187
|
-
)
|
|
188
|
-
else:
|
|
189
|
-
together_finish = "stop"
|
|
190
|
-
tool_calls = None
|
|
191
|
-
|
|
192
|
-
# 3. convert output
|
|
193
|
-
message = ChatCompletionMessage(
|
|
194
|
-
role="assistant",
|
|
195
|
-
content=response.choices[0].message.content,
|
|
196
|
-
function_call=None,
|
|
197
|
-
tool_calls=tool_calls,
|
|
198
|
-
)
|
|
199
|
-
choices = [Choice(finish_reason=together_finish, index=0, message=message)]
|
|
200
|
-
|
|
201
|
-
response_oai = ChatCompletion(
|
|
202
|
-
id=response.id,
|
|
203
|
-
model=together_params["model"],
|
|
204
|
-
created=int(time.time()),
|
|
205
|
-
object="chat.completion",
|
|
206
|
-
choices=choices,
|
|
207
|
-
usage=CompletionUsage(
|
|
208
|
-
prompt_tokens=prompt_tokens,
|
|
209
|
-
completion_tokens=completion_tokens,
|
|
210
|
-
total_tokens=total_tokens,
|
|
211
|
-
),
|
|
212
|
-
cost=calculate_together_cost(prompt_tokens, completion_tokens, together_params["model"]),
|
|
213
|
-
)
|
|
214
|
-
|
|
215
|
-
return response_oai
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
def oai_messages_to_together_messages(messages: list[Dict[str, Any]]) -> list[dict[str, Any]]:
|
|
219
|
-
"""Convert messages from OAI format to Together.AI format.
|
|
220
|
-
We correct for any specific role orders and types.
|
|
221
|
-
"""
|
|
222
|
-
|
|
223
|
-
together_messages = copy.deepcopy(messages)
|
|
224
|
-
|
|
225
|
-
# If we have a message with role='tool', which occurs when a function is executed, change it to 'user'
|
|
226
|
-
for msg in together_messages:
|
|
227
|
-
if "role" in msg and msg["role"] == "tool":
|
|
228
|
-
msg["role"] = "user"
|
|
229
|
-
|
|
230
|
-
return together_messages
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
# MODELS AND COSTS
|
|
234
|
-
chat_lang_code_model_sizes = {
|
|
235
|
-
"zero-one-ai/Yi-34B-Chat": 34,
|
|
236
|
-
"allenai/OLMo-7B-Instruct": 7,
|
|
237
|
-
"allenai/OLMo-7B-Twin-2T": 7,
|
|
238
|
-
"allenai/OLMo-7B": 7,
|
|
239
|
-
"Austism/chronos-hermes-13b": 13,
|
|
240
|
-
"deepseek-ai/deepseek-coder-33b-instruct": 33,
|
|
241
|
-
"deepseek-ai/deepseek-llm-67b-chat": 67,
|
|
242
|
-
"garage-bAInd/Platypus2-70B-instruct": 70,
|
|
243
|
-
"google/gemma-2b-it": 2,
|
|
244
|
-
"google/gemma-7b-it": 7,
|
|
245
|
-
"Gryphe/MythoMax-L2-13b": 13,
|
|
246
|
-
"lmsys/vicuna-13b-v1.5": 13,
|
|
247
|
-
"lmsys/vicuna-7b-v1.5": 7,
|
|
248
|
-
"codellama/CodeLlama-13b-Instruct-hf": 13,
|
|
249
|
-
"codellama/CodeLlama-34b-Instruct-hf": 34,
|
|
250
|
-
"codellama/CodeLlama-70b-Instruct-hf": 70,
|
|
251
|
-
"codellama/CodeLlama-7b-Instruct-hf": 7,
|
|
252
|
-
"meta-llama/Llama-2-70b-chat-hf": 70,
|
|
253
|
-
"meta-llama/Llama-2-13b-chat-hf": 13,
|
|
254
|
-
"meta-llama/Llama-2-7b-chat-hf": 7,
|
|
255
|
-
"meta-llama/Llama-3-8b-chat-hf": 8,
|
|
256
|
-
"meta-llama/Llama-3-70b-chat-hf": 70,
|
|
257
|
-
"mistralai/Mistral-7B-Instruct-v0.1": 7,
|
|
258
|
-
"mistralai/Mistral-7B-Instruct-v0.2": 7,
|
|
259
|
-
"mistralai/Mistral-7B-Instruct-v0.3": 7,
|
|
260
|
-
"NousResearch/Nous-Capybara-7B-V1p9": 7,
|
|
261
|
-
"NousResearch/Nous-Hermes-llama-2-7b": 7,
|
|
262
|
-
"NousResearch/Nous-Hermes-Llama2-13b": 13,
|
|
263
|
-
"NousResearch/Nous-Hermes-2-Yi-34B": 34,
|
|
264
|
-
"openchat/openchat-3.5-1210": 7,
|
|
265
|
-
"Open-Orca/Mistral-7B-OpenOrca": 7,
|
|
266
|
-
"Qwen/Qwen1.5-0.5B-Chat": 0.5,
|
|
267
|
-
"Qwen/Qwen1.5-1.8B-Chat": 1.8,
|
|
268
|
-
"Qwen/Qwen1.5-4B-Chat": 4,
|
|
269
|
-
"Qwen/Qwen1.5-7B-Chat": 7,
|
|
270
|
-
"Qwen/Qwen1.5-14B-Chat": 14,
|
|
271
|
-
"Qwen/Qwen1.5-32B-Chat": 32,
|
|
272
|
-
"Qwen/Qwen1.5-72B-Chat": 72,
|
|
273
|
-
"Qwen/Qwen1.5-110B-Chat": 110,
|
|
274
|
-
"Qwen/Qwen2-72B-Instruct": 72,
|
|
275
|
-
"snorkelai/Snorkel-Mistral-PairRM-DPO": 7,
|
|
276
|
-
"togethercomputer/alpaca-7b": 7,
|
|
277
|
-
"teknium/OpenHermes-2-Mistral-7B": 7,
|
|
278
|
-
"teknium/OpenHermes-2p5-Mistral-7B": 7,
|
|
279
|
-
"togethercomputer/Llama-2-7B-32K-Instruct": 7,
|
|
280
|
-
"togethercomputer/RedPajama-INCITE-Chat-3B-v1": 3,
|
|
281
|
-
"togethercomputer/RedPajama-INCITE-7B-Chat": 7,
|
|
282
|
-
"togethercomputer/StripedHyena-Nous-7B": 7,
|
|
283
|
-
"Undi95/ReMM-SLERP-L2-13B": 13,
|
|
284
|
-
"Undi95/Toppy-M-7B": 7,
|
|
285
|
-
"WizardLM/WizardLM-13B-V1.2": 13,
|
|
286
|
-
"upstage/SOLAR-10.7B-Instruct-v1.0": 11,
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
# Cost per million tokens based on up to X Billion parameters, e.g. up 4B is $0.1/million
|
|
290
|
-
chat_lang_code_model_costs = {4: 0.1, 8: 0.2, 21: 0.3, 41: 0.8, 80: 0.9, 110: 1.8}
|
|
291
|
-
|
|
292
|
-
mixture_model_sizes = {
|
|
293
|
-
"cognitivecomputations/dolphin-2.5-mixtral-8x7b": 56,
|
|
294
|
-
"databricks/dbrx-instruct": 132,
|
|
295
|
-
"mistralai/Mixtral-8x7B-Instruct-v0.1": 47,
|
|
296
|
-
"mistralai/Mixtral-8x22B-Instruct-v0.1": 141,
|
|
297
|
-
"NousResearch/Nous-Hermes-2-Mistral-7B-DPO": 7,
|
|
298
|
-
"NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO": 47,
|
|
299
|
-
"NousResearch/Nous-Hermes-2-Mixtral-8x7B-SFT": 47,
|
|
300
|
-
"Snowflake/snowflake-arctic-instruct": 480,
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
# Cost per million tokens based on up to X Billion parameters, e.g. up 56B is $0.6/million
|
|
304
|
-
mixture_costs = {56: 0.6, 176: 1.2, 480: 2.4}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
def calculate_together_cost(input_tokens: int, output_tokens: int, model_name: str) -> float:
|
|
308
|
-
"""Cost calculation for inference"""
|
|
309
|
-
|
|
310
|
-
if model_name in chat_lang_code_model_sizes or model_name in mixture_model_sizes:
|
|
311
|
-
cost_per_mil = 0
|
|
312
|
-
|
|
313
|
-
# Chat, Language, Code models
|
|
314
|
-
if model_name in chat_lang_code_model_sizes:
|
|
315
|
-
size_in_b = chat_lang_code_model_sizes[model_name]
|
|
316
|
-
|
|
317
|
-
for top_size in chat_lang_code_model_costs.keys():
|
|
318
|
-
if size_in_b <= top_size:
|
|
319
|
-
cost_per_mil = chat_lang_code_model_costs[top_size]
|
|
320
|
-
break
|
|
321
|
-
|
|
322
|
-
else:
|
|
323
|
-
# Mixture-of-experts
|
|
324
|
-
size_in_b = mixture_model_sizes[model_name]
|
|
325
|
-
|
|
326
|
-
for top_size in mixture_costs.keys():
|
|
327
|
-
if size_in_b <= top_size:
|
|
328
|
-
cost_per_mil = mixture_costs[top_size]
|
|
329
|
-
break
|
|
330
|
-
|
|
331
|
-
if cost_per_mil == 0:
|
|
332
|
-
warnings.warn("Model size doesn't align with cost structure.", UserWarning)
|
|
333
|
-
|
|
334
|
-
return cost_per_mil * ((input_tokens + output_tokens) / 1e6)
|
|
335
|
-
|
|
336
|
-
else:
|
|
337
|
-
# Model is not in our list of models, can't determine the cost
|
|
338
|
-
warnings.warn(
|
|
339
|
-
"The model isn't catered for costing, to apply costs you can use the 'price' key on your config_list.",
|
|
340
|
-
UserWarning,
|
|
341
|
-
)
|
|
342
|
-
|
|
343
|
-
return 0
|