Find answers from the community

Updated 3 months ago

Query

L
a
5 comments
It's a string variable thar gets filled in later by llama_index automatically
i changed it this way
Plain Text
 class Biography(BaseModel):
    """Data model for a biography."""

    name: str
    best_known_for: List[str]
    extra_info: str

 # setup prompts - specific to StableLM
from llama_index.prompts import PromptTemplate
query_str = "Your task instruction goes here."
# This will wrap the default prompts that are internal to llama-index
# taken from https://huggingface.co/Writer/camel-5b-hf
prompt = (f'Below is an instruction that describes a task. \n'
    f'Write a response that appropriately completes the request.\n'
    f'"### Instruction:\n{query_str}\n\n### Response:": {Biography.schema_json()} :\n')

query_wrapper_prompt = PromptTemplate(prompt)
otherwise it throws an Valueerror: query_str
The query_str gets filled in with whatever you query with

query_engine.query("hello")
@Logan M still getting issues, is this correct?
Plain Text
DEFAULT_SYSTEM_PROMPT = """\
You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe.  Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.\n\nIf a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.\
"""

def get_prompt(message: str, system_prompt: str = DEFAULT_SYSTEM_PROMPT) -> str:
    return f'<s>[INST] <<SYS>>\n{system_prompt}\n<</SYS>>\n\n{message} [/INST]'

class Biography(BaseModel):
    """Data model for a biography."""

    name: str
    best_known_for: List[str]
    extra_info: str

 # setup prompts - specific to StableLM
from llama_index.prompts import PromptTemplate

# This will wrap the default prompts that are internal to llama-index
query_str = "Your task instruction goes here."
prompt = (f'Below is an instruction that describes a task. \n'
    f'Write a response that appropriately completes the request.\n'
    f'"### Instruction:\n{query_str}\n\n### Response:": {Biography.schema_json()} :\n')

prompt = get_prompt(prompt)
Add a reply
Sign up and join the conversation on Discord