airtrain 0.1.27__py3-none-any.whl → 0.1.29__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.
airtrain/__init__.py CHANGED
@@ -1,6 +1,6 @@
1
1
  """Airtrain - A platform for building and deploying AI agents with structured skills"""
2
2
 
3
- __version__ = "0.1.27"
3
+ __version__ = "0.1.29"
4
4
 
5
5
  # Core imports
6
6
  from .core.skills import Skill, ProcessingError
@@ -3,6 +3,7 @@ from pydantic import BaseModel, Field
3
3
  import requests
4
4
  import json
5
5
  from loguru import logger
6
+ import re
6
7
 
7
8
  from airtrain.core.skills import Skill, ProcessingError
8
9
  from airtrain.core.schemas import InputSchema, OutputSchema
@@ -47,6 +48,7 @@ class FireworksStructuredRequestOutput(OutputSchema):
47
48
  parsed_response: Any
48
49
  used_model: str
49
50
  usage: Dict[str, int]
51
+ reasoning: Optional[str] = None
50
52
 
51
53
 
52
54
  class FireworksStructuredRequestSkill(
@@ -128,19 +130,33 @@ class FireworksStructuredRequestSkill(
128
130
  except json.JSONDecodeError:
129
131
  continue
130
132
 
131
- # Once complete, parse the full JSON
132
- complete_json = "".join(json_buffer)
133
+ # Once complete, parse the full response with think tags
134
+ complete_response = "".join(json_buffer)
135
+ reasoning, json_str = self._parse_response_content(complete_response)
136
+
133
137
  try:
134
138
  parsed_response = input_data.response_model.model_validate_json(
135
- complete_json
139
+ json_str
136
140
  )
137
- yield {"complete": parsed_response}
141
+ yield {"complete": parsed_response, "reasoning": reasoning}
138
142
  except Exception as e:
139
143
  raise ProcessingError(f"Failed to parse JSON response: {str(e)}")
140
144
 
141
145
  except Exception as e:
142
146
  raise ProcessingError(f"Fireworks streaming request failed: {str(e)}")
143
147
 
148
+ def _parse_response_content(self, content: str) -> tuple[Optional[str], str]:
149
+ """Parse response content to extract reasoning and JSON."""
150
+ # Extract reasoning if present
151
+ reasoning_match = re.search(r"<think>(.*?)</think>", content, re.DOTALL)
152
+ reasoning = reasoning_match.group(1).strip() if reasoning_match else None
153
+
154
+ # Extract JSON
155
+ json_match = re.search(r"</think>\s*(\{.*\})", content, re.DOTALL)
156
+ json_str = json_match.group(1).strip() if json_match else content
157
+
158
+ return reasoning, json_str
159
+
144
160
  def process(
145
161
  self, input_data: FireworksStructuredRequestInput
146
162
  ) -> FireworksStructuredRequestOutput:
@@ -150,12 +166,14 @@ class FireworksStructuredRequestSkill(
150
166
  # For streaming, collect and parse the entire response
151
167
  json_buffer = []
152
168
  parsed_response = None
169
+ reasoning = None
153
170
 
154
171
  for chunk in self.process_stream(input_data):
155
172
  if "chunk" in chunk:
156
173
  json_buffer.append(chunk["chunk"])
157
174
  elif "complete" in chunk:
158
175
  parsed_response = chunk["complete"]
176
+ reasoning = chunk.get("reasoning")
159
177
 
160
178
  if parsed_response is None:
161
179
  raise ProcessingError("Failed to parse streamed response")
@@ -164,6 +182,7 @@ class FireworksStructuredRequestSkill(
164
182
  parsed_response=parsed_response,
165
183
  used_model=input_data.model,
166
184
  usage={}, # Usage stats not available in streaming mode
185
+ reasoning=reasoning,
167
186
  )
168
187
  else:
169
188
  # For non-streaming, use regular request
@@ -175,14 +194,20 @@ class FireworksStructuredRequestSkill(
175
194
  data = response.json()
176
195
 
177
196
  response_content = data["choices"][0]["message"]["content"]
197
+
198
+ # Parse the response content to extract reasoning and JSON
199
+ reasoning, json_str = self._parse_response_content(response_content)
200
+
201
+ # Parse the JSON string into the specified model
178
202
  parsed_response = input_data.response_model.model_validate_json(
179
- response_content
203
+ json_str
180
204
  )
181
205
 
182
206
  return FireworksStructuredRequestOutput(
183
207
  parsed_response=parsed_response,
184
208
  used_model=input_data.model,
185
209
  usage=data["usage"],
210
+ reasoning=reasoning, # Add reasoning to output if present
186
211
  )
187
212
 
188
213
  except Exception as e:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: airtrain
3
- Version: 0.1.27
3
+ Version: 0.1.29
4
4
  Summary: A platform for building and deploying AI agents with structured skills
5
5
  Home-page: https://github.com/rosaboyle/airtrain.dev
6
6
  Author: Dheeraj Pai
@@ -171,6 +171,12 @@ This project is licensed under the MIT License - see the LICENSE file for detail
171
171
  ## Changelog
172
172
 
173
173
 
174
+
175
+ ## 0.1.28
176
+
177
+ - Bug fix: reasoning to Fireworks structured output.
178
+ - Added reasoning to Fireworks structured output.
179
+
174
180
  ## 0.1.27
175
181
 
176
182
  - Added structured completion skills for Fireworks AI
@@ -1,4 +1,4 @@
1
- airtrain/__init__.py,sha256=XNINrhMBMu3SCd5wCDb2FLhe3OfbvZqWFEvVwcRKtm0,2099
1
+ airtrain/__init__.py,sha256=KwgaA3OIuQa6v6bg6dmrZp2drOpIlUw6oF08GZjprfA,2099
2
2
  airtrain/contrib/__init__.py,sha256=pG-7mJ0pBMqp3Q86mIF9bo1PqoBOVSGlnEK1yY1U1ok,641
3
3
  airtrain/contrib/travel/__init__.py,sha256=clmBodw4nkTA-DsgjVGcXfJGPaWxIpCZDtdO-8RzL0M,811
4
4
  airtrain/contrib/travel/agents.py,sha256=tpQtZ0WUiXBuhvZtc2JlEam5TuR5l-Tndi14YyImDBM,8975
@@ -25,7 +25,7 @@ airtrain/integrations/fireworks/models.py,sha256=F-MddbLCLAsTjwRr1l6IpJxOegyY4pD
25
25
  airtrain/integrations/fireworks/requests_skills.py,sha256=zPIR70l0KdSGmA5WyDEopFAdKHSPltAttJBzWyHu6Bk,5878
26
26
  airtrain/integrations/fireworks/skills.py,sha256=OB4epD4CSTxExUCC1oMJ_8rHLOoftlxf0FUoIVrd4mA,5163
27
27
  airtrain/integrations/fireworks/structured_completion_skills.py,sha256=IXG4gsZDSfuscrmKIHfnyHkBaCV7zlPInaWXb95iC5k,6428
28
- airtrain/integrations/fireworks/structured_requests_skills.py,sha256=3JJqyQ3zyWvAhb_cXKGuSKUo7XZduKtQf1814CvY1Co,7244
28
+ airtrain/integrations/fireworks/structured_requests_skills.py,sha256=oRpbKMOcKgY2js16uNkIx866UEwEYSNgFPNYn9cLO3U,8409
29
29
  airtrain/integrations/fireworks/structured_skills.py,sha256=BZaLqSOTC11QdZ4kDORS4JnwF_YXBAa-IiwQ5dJiHXw,3895
30
30
  airtrain/integrations/google/__init__.py,sha256=ElwgcXfbg_gGMm6zbkMXCQPFKZUb-yTJk986o19A7Cs,214
31
31
  airtrain/integrations/google/credentials.py,sha256=KSvWNqW8Mjr4MkysRvUqlrOSGdShNIe5u2OPO6vRrWY,2047
@@ -57,7 +57,7 @@ airtrain/integrations/together/rerank_skill.py,sha256=gjH24hLWCweWKPyyfKZMG3K_g9
57
57
  airtrain/integrations/together/schemas.py,sha256=pBMrbX67oxPCr-sg4K8_Xqu1DWbaC4uLCloVSascROg,1210
58
58
  airtrain/integrations/together/skills.py,sha256=mUoHc2r5TYQi5iGzwz2aDuUeROGq7teCtNrOlNApef4,6276
59
59
  airtrain/integrations/together/vision_models_config.py,sha256=m28HwYDk2Kup_J-a1FtynIa2ZVcbl37kltfoHnK8zxs,1544
60
- airtrain-0.1.27.dist-info/METADATA,sha256=6TUG7xaOytkupjRdIx_3me_rVaApKtY9T1wZwgvh1jA,5127
61
- airtrain-0.1.27.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
62
- airtrain-0.1.27.dist-info/top_level.txt,sha256=cFWW1vY6VMCb3AGVdz6jBDpZ65xxBRSqlsPyySxTkxY,9
63
- airtrain-0.1.27.dist-info/RECORD,,
60
+ airtrain-0.1.29.dist-info/METADATA,sha256=R_xdPE4QQ8KN9dUG4NN-PRiP02GOVKBNSB_Qtemyaig,5243
61
+ airtrain-0.1.29.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
62
+ airtrain-0.1.29.dist-info/top_level.txt,sha256=cFWW1vY6VMCb3AGVdz6jBDpZ65xxBRSqlsPyySxTkxY,9
63
+ airtrain-0.1.29.dist-info/RECORD,,