MCPcopy Create free account
hub / github.com/algorithmicsuperintelligence/optillm / preprocess_input

Function preprocess_input

optillm/plugins/router_plugin.py:65–76  ·  view source on GitHub ↗
(tokenizer, system_prompt, initial_query)

Source from the content-addressed store, hash-verified

63 return model, tokenizer, device
64
65def preprocess_input(tokenizer, system_prompt, initial_query):
66 combined_input = f"{system_prompt}\n\nUser: {initial_query}"
67 encoding = tokenizer.encode_plus(
68 combined_input,
69 add_special_tokens=True,
70 max_length=MAX_LENGTH,
71 padding='max_length',
72 truncation=True,
73 return_attention_mask=True,
74 return_tensors='pt'
75 )
76 return encoding['input_ids'], encoding['attention_mask']
77
78def predict_approach(model, input_ids, attention_mask, device, effort=0.7):
79 model.eval()

Callers 1

runFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected