MCPcopy
hub / github.com/microsoft/JARVIS / parse_task

Function parse_task

hugginggpt/server/awesome_chat.py:317–348  ·  view source on GitHub ↗
(context, input, api_key, api_type, api_endpoint)

Source from the content-addressed store, hash-verified

315 return send_request(data)
316
317def parse_task(context, input, api_key, api_type, api_endpoint):
318 demos_or_presteps = parse_task_demos_or_presteps
319 messages = json.loads(demos_or_presteps)
320 messages.insert(0, {"role": "system", "content": parse_task_tprompt})
321
322 # cut chat logs
323 start = 0
324 while start <= len(context):
325 history = context[start:]
326 prompt = replace_slot(parse_task_prompt, {
327 "input": input,
328 "context": history
329 })
330 messages.append({"role": "user", "content": prompt})
331 history_text = "<im_end>\nuser<im_start>".join([m["content"] for m in messages])
332 num = count_tokens(LLM_encoding, history_text)
333 if get_max_context_length(LLM) - num > 800:
334 break
335 messages.pop()
336 start += 2
337
338 logger.debug(messages)
339 data = {
340 "model": LLM,
341 "messages": messages,
342 "temperature": 0,
343 "logit_bias": {item: config["logit_bias"]["parse_task"] for item in task_parsing_highlight_ids},
344 "api_key": api_key,
345 "api_type": api_type,
346 "api_endpoint": api_endpoint
347 }
348 return send_request(data)
349
350def choose_model(input, task, metas, api_key, api_type, api_endpoint):
351 prompt = replace_slot(choose_model_prompt, {

Callers 1

chat_huggingfaceFunction · 0.85

Calls 4

count_tokensFunction · 0.90
get_max_context_lengthFunction · 0.90
replace_slotFunction · 0.85
send_requestFunction · 0.85

Tested by

no test coverage detected