2023-10-06 18:54:12 +00:00
|
|
|
import re
|
|
|
|
|
import requests
|
|
|
|
|
import streamlit as st
|
|
|
|
|
from typing import NamedTuple
|
|
|
|
|
|
|
|
|
|
# force wide mode
|
|
|
|
|
st.set_page_config(layout="wide")
|
|
|
|
|
|
|
|
|
|
language = st.text_input("Language", "rust")
|
2023-10-07 01:40:21 +00:00
|
|
|
|
2023-10-13 02:27:52 +00:00
|
|
|
query = st.text_area("Query", "to_owned")
|
2023-10-06 18:54:12 +00:00
|
|
|
|
|
|
|
|
if query:
|
2023-10-13 02:27:52 +00:00
|
|
|
r = requests.post("http://localhost:8080/v1/completions", json=dict(segments=dict(prefix=query), language=language, debug=dict(enabled=True)))
|
|
|
|
|
json = r.json()
|
|
|
|
|
debug = json["debug_data"]
|
|
|
|
|
snippets = debug.get("snippets", [])
|
|
|
|
|
|
|
|
|
|
st.write("Prompt")
|
|
|
|
|
st.code(debug["prompt"])
|
|
|
|
|
|
|
|
|
|
st.write("Completion")
|
|
|
|
|
st.code(json["choices"][0]["text"])
|
|
|
|
|
|
|
|
|
|
for x in snippets:
|
|
|
|
|
st.write(f"**{x['filepath']}**: {x['score']}")
|
|
|
|
|
st.write(f"Length: {len(x['body'])}")
|
|
|
|
|
st.code(x['body'])
|