python-fastllm 0.0.68__py3-none-any.whl → 0.0.69__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.
fastllm/__init__.py CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  - `fastllm.responses`: Provider-independent Responses resources and streaming over FastLLM"""
4
4
 
5
- __version__ = "0.0.68"
5
+ __version__ = "0.0.69"
fastllm/_modidx.py CHANGED
@@ -274,6 +274,8 @@ d = { 'settings': { 'branch': 'main',
274
274
  'fastllm/responses.py'),
275
275
  'fastllm.responses.AsyncResponses.prepare': ( 'responses.html#asyncresponses.prepare',
276
276
  'fastllm/responses.py'),
277
+ 'fastllm.responses.AsyncResponses.provider_kwargs': ( 'responses.html#asyncresponses.provider_kwargs',
278
+ 'fastllm/responses.py'),
277
279
  'fastllm.responses.AsyncResponses.serve': ( 'responses.html#asyncresponses.serve',
278
280
  'fastllm/responses.py'),
279
281
  'fastllm.responses.AsyncResponses.server_results': ( 'responses.html#asyncresponses.server_results',
fastllm/responses.py CHANGED
@@ -1,6 +1,6 @@
1
1
  """Provider-independent Responses resources and streaming over FastLLM
2
2
 
3
- `response_input` accepts a prompt string or an input-item array. It returns `(messages, instructions)`. System and developer text goes in the instructions; the remaining items become shared messages.
3
+ `response_input` accepts a prompt string, Responses input items, or canonical `msg2dict` messages. It returns `(messages, instructions)`. System and developer text becomes instructions. Canonical messages preserve provider replay data.
4
4
 
5
5
  `normalize_call_ids` supplies missing client call IDs before we retain the history. Later tool results can refer to the same IDs that the client received.
6
6
 
@@ -62,7 +62,10 @@ def response_input(inp):
62
62
  pending_tools.clear()
63
63
  for item in inp:
64
64
  typ = item.get('type')
65
- if typ in ('message', 'easy_input_message') or 'role' in item:
65
+ if 'raw_api' in item:
66
+ flush_tools()
67
+ msgs.append(dict2msg(item))
68
+ elif typ in ('message', 'easy_input_message') or 'role' in item:
66
69
  flush_tools()
67
70
  role = item.get('role', 'user')
68
71
  if role in ('system', 'developer'): systems.append(_text_content(item.get('content', '')))
@@ -144,7 +147,7 @@ def response_usage(usage):
144
147
  def _response_base(rid, body, previous_response_id=None, created_at=None):
145
148
  result = dict(id=rid, object='response', created_at=int(created_at or time.time()), instructions=body.get('instructions'), model=body['model'])
146
149
  result.update(parallel_tool_calls=body.get('parallel_tool_calls', True), previous_response_id=previous_response_id,
147
- reasoning=body.get('reasoning'), store=True, prompt_cache_key=body.get('prompt_cache_key'), temperature=body.get('temperature'))
150
+ reasoning=body.get('reasoning'), store=body.get('store', True), prompt_cache_key=body.get('prompt_cache_key'), temperature=body.get('temperature'))
148
151
  result.update(text=body.get('text', {'format':{'type':'text'}}), tool_choice=body.get('tool_choice', 'auto'),
149
152
  tools=body.get('tools', []), top_p=body.get('top_p'), metadata=body.get('metadata', {}))
150
153
  return result
@@ -243,16 +246,21 @@ class AsyncResponses:
243
246
 
244
247
  # %% ../nbs/08_responses.ipynb #373f7d5e
245
248
  @patch
246
- async def call(self:AsyncResponses, turn):
247
- "Start the provider stream for a prepared turn, having received its first chunk; the turn's `call_kwargs` reach `acomplete`"
249
+ def provider_kwargs(self:AsyncResponses, turn):
250
+ "Provider request options shared by calling and input inspection"
248
251
  body = turn.body
249
252
  reasoning = body.get('reasoning') or {}
250
253
  tools = list(body.get('tools') or []) + [dict(type='function', **get_schema(f, pname='parameters')) for f in turn.server_tools.values()]
251
- kwargs = dict(previous_response_id=turn.provider_previous_id, system=turn.system or None, tools=tools or None)
254
+ kwargs = dict(model=body['model'], previous_response_id=turn.provider_previous_id, system=turn.system or None, tools=tools or None)
252
255
  kwargs.update(prompt_cache_key=body['prompt_cache_key'], tool_choice=body.get('tool_choice'), parallel_tool_calls=body.get('parallel_tool_calls', True),
253
256
  reasoning_effort=reasoning.get('effort'), max_tokens=body.get('max_output_tokens'), temperature=body.get('temperature'),
254
257
  cache_idxs=body.get('cache_idxs'), ttl=body.get('ttl'), web_search_options=body.get('web_search_options'))
255
- stream = await acomplete(turn.provider_messages, model=body['model'], stream=True, **kwargs, **turn.call_kwargs)
258
+ return kwargs
259
+
260
+ @patch
261
+ async def call(self:AsyncResponses, turn):
262
+ "Start a provider stream, waiting for its first chunk before returning"
263
+ stream = await acomplete(turn.provider_messages, stream=True, **self.provider_kwargs(turn), **turn.call_kwargs)
256
264
  first = await anext(stream)
257
265
  async def _rest():
258
266
  yield first
@@ -458,6 +466,7 @@ async def events(self:AsyncResponses, turn, finalize=None, stream=None):
458
466
  comp.message,comp.usage = Msg('assistant', prior + _visible_parts(comp.message.content, results)),usage
459
467
  for event in state.done_events(comp): yield event
460
468
  response = response_object(first.id, first.body, comp, first.previous.id if first.previous else None, first.created_at)
469
+ response['messages'] = [msg2dict(m) for m in next_state.history[len(first.history):]]
461
470
  if finalize and (extra := await finalize(next_state, comp)): response['usage'].update(extra)
462
471
  name = 'response.incomplete' if response['status'] == 'incomplete' else 'response.completed'
463
472
  yield state.event(name, response=response)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-fastllm
3
- Version: 0.0.68
3
+ Version: 0.0.69
4
4
  Author-email: Kerem Turgutlu <keremturgutlu@gmail.com>
5
5
  License-Expression: Apache-2.0
6
6
  Project-URL: Repository, https://github.com/AnswerDotAI/fastllm
@@ -1,5 +1,5 @@
1
- fastllm/__init__.py,sha256=dQzPsBk6KhT2Gudv8udu5xeea2ngpFEuIRClzyiKnv0,131
2
- fastllm/_modidx.py,sha256=G6B334J26CNKFkssHUoOedWDtZzn2i0wCe27CB_ebgk,48651
1
+ fastllm/__init__.py,sha256=FJwRJilksEyKe-Dv8ZG_kdMT6ekH2PaS_Ugv48qhECw,131
2
+ fastllm/_modidx.py,sha256=-Cj_pdXF05ZGRjKbBDgMb-lhWXQXLiCLEuyiePF8kiM,48903
3
3
  fastllm/acomplete.py,sha256=2eKl9EFDryw3vpf8tR-SAmdhFQZEVCHyOaBcYnGqlqk,11758
4
4
  fastllm/anthropic.py,sha256=Ex0i3XC6wd8GvvkGCB2eLcIjG9I02ULhCFcgsUSxEdc,19317
5
5
  fastllm/chat.py,sha256=p0j2kChKvgTnsGe2Et-XVjW5oWNhUwgO27qjhy9Zais,25515
@@ -8,11 +8,11 @@ fastllm/gemini.py,sha256=hP53t9AbdGoUfumvFVy7c1DAceJts4mGd0qexxY8awU,17757
8
8
  fastllm/model_prices.json,sha256=qcGF-WRr8kMCeKWtE5Zv3xkx3j6Xlh3UbXPqoyF0jng,3190018
9
9
  fastllm/openai_chat.py,sha256=d4W6DDP4oasjaGQytmltSWs6EaXx7kWdjFIQTO6mljI,13246
10
10
  fastllm/openai_responses.py,sha256=jcjVQ9_PfjdNudoUoCZMGsIWUG5S-RsPhQ0vP7JB2LI,15532
11
- fastllm/responses.py,sha256=JQma6x33z2XIqhvz1xVseYbqoaPIZpSAQ04Vntbyk70,26605
11
+ fastllm/responses.py,sha256=veeXniqIrJ9fhGbJh0HojDNnEGXv1Ha577z_7_m1CK0,26963
12
12
  fastllm/streaming.py,sha256=8RYbFoENDzfZbwR1eM1q_xOpnCDHP8h4EFZXOLG4g2w,8787
13
13
  fastllm/types.py,sha256=wfBWVDbQucpXU5ygUbW_-2N1qsdiLXsQUrDNmwQsi4o,21324
14
- python_fastllm-0.0.68.dist-info/METADATA,sha256=pTzZgZcym3q4XIgIvPMMux4h4sMnGeiGP7HYO4OtWoA,8901
15
- python_fastllm-0.0.68.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
16
- python_fastllm-0.0.68.dist-info/entry_points.txt,sha256=WkWd04F3xVYFP5bsexaQe9Se6uelwE5ULoTtHWreO0s,133
17
- python_fastllm-0.0.68.dist-info/top_level.txt,sha256=F8qodL7nEGUHGmzzqfhNKCTIr1i0D6cvudOnm3z7o0Y,8
18
- python_fastllm-0.0.68.dist-info/RECORD,,
14
+ python_fastllm-0.0.69.dist-info/METADATA,sha256=K9toNfLIYD6GoHj5zUiUBO6Ky8_6TC1THBMBYaqlMew,8901
15
+ python_fastllm-0.0.69.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
16
+ python_fastllm-0.0.69.dist-info/entry_points.txt,sha256=WkWd04F3xVYFP5bsexaQe9Se6uelwE5ULoTtHWreO0s,133
17
+ python_fastllm-0.0.69.dist-info/top_level.txt,sha256=F8qodL7nEGUHGmzzqfhNKCTIr1i0D6cvudOnm3z7o0Y,8
18
+ python_fastllm-0.0.69.dist-info/RECORD,,