CoolFace
Apppublic

as-cle-bert/SearchPhi

sourceHugging Facemitupdated 2y agoView on Hugging Face
16likes
llama_cpp_inf.py25 linesDownload Raw Back to root
1## Imports2import re3from huggingface_hub import hf_hub_download4from gradio_client import Client5 6api_client = Client("eswardivi/Phi-3-mini-128k-instruct")7 8def run_inference_lcpp(jsonstr, user_search):9    prompt = f"""Instructions for the assistant: Starting from the URLs and the keywords deriving from Google search results and provided to you in JSON format, generate a meaningful summary of the search results that satisfies the user's query.10    URLs and keywords in JSON format: {jsonstr}.11    User's query to satisfy: {user_search}"""12    response = api_client.predict(13        prompt,	# str  in 'Message' Textbox component14        0.2,	# float (numeric value between 0 and 1) in 'Temperature' Slider component15        True,	# bool  in 'Sampling' Checkbox component16        512,	# float (numeric value between 128 and 4096) in 'Max new tokens' Slider component17        api_name="/chat"18    )19    jsondict = eval(jsonstr)20    addon = "Reference websites:\n- "+ '\n- '.join(list(jsondict.keys()))21    input_string = response + "\n\n" + addon22    frag_res = re.findall(r'\w+|\s+|[^\w\s]', input_string)23    for word in frag_res:24        yield word25