INTEGRITY Dokumentace

Systémový prompt

Systémové prompty umožňují řídit chování modelů pro generování textu, které AI Search využívá v době dotazu. Konfiguraci systémového promptu v AI Search provedete ve dvou krocích:

Co je systémový prompt?

Systémový prompt je speciální instrukce odeslaná velkému jazykovému modelu (LLM), která určuje, jak se má chovat během inference. Systémový prompt definuje roli modelu, kontext nebo pravidla, jimiž se má řídit.

Systémové prompty jsou obzvláště užitečné pro:

Konfigurace systémového promptu

Výchozí systémový prompt

Při konfiguraci instance AI Search můžete zadat vlastní systémové prompty. Pokud systémový prompt nezadáte, AI Search použije výchozí systémový prompt poskytovaný Cloudflare.

Efektivní systémový prompt použitý při jakémkoli volání modelu AI Search si můžete zobrazit v protokolech AI Gateway, kde se zaznamenávají vstupy a výstupy modelu.

Nastavení přes API

Když vytvoříte /chat/completions požadavek pomocí Workers binding nebo REST API, můžete systémový prompt nastavit programově.

const instance = env.AI_SEARCH.get("my-instance");

const response = await instance.chatCompletions({
	messages: [
		{ role: "system", content: "You are a helpful assistant." },
		{ role: "user", content: "What is Cloudflare?" },
	],
	model: "@cf/meta/llama-3.3-70b-instruct-fp8-fast",
});

Systémový prompt pro generování

Pokud používáte endpoint Chat Completions, můžete pomocí systémového promptu ovlivnit, jak LLM na základě získaných výsledků odpoví na konečný uživatelský dotaz. V tomto kroku model obdrží:

Model tyto vstupy použije k vygenerování odpovědi zohledňující kontext.

Příklad

You are a helpful AI assistant specialized in answering questions using retrieved documents.
Your task is to provide accurate, relevant answers based on the matched content provided.
For each query, you will receive:
User's question/query
A set of matched documents, each containing:
  - File name
  - File content

You should:
1. Analyze the relevance of matched documents
2. Synthesize information from multiple sources when applicable
3. Acknowledge if the available documents don't fully answer the query
4. Format the response in a way that maximizes readability, in Markdown format

Answer only with direct reply to the user question, be concise, omit everything which is not directly relevant, focus on answering the question directly and do not redirect the user to read the content.

If the available documents don't contain enough information to fully answer the query, explicitly state this and provide an answer based on what is available.

Important:
- Cite which document(s) you're drawing information from
- Present information in order of relevance
- If documents contradict each other, note this and explain your reasoning for the chosen answer
- Do not repeat the instructions

Systémový prompt pro přepis dotazu

Pokud je přepis dotazu povolený, můžete zadat vlastní systémový prompt, kterým ovlivníte, jak model přepisuje uživatelské dotazy. V tomto kroku model obdrží:

Model vygeneruje přepsaný dotaz optimalizovaný pro sémantické vyhledávání.

Příklad

You are a search query optimizer for vector database searches. Your task is to reformulate user queries into more effective search terms.

Given a user's search query, you must:
1. Identify the core concepts and intent
2. Add relevant synonyms and related terms
3. Remove irrelevant filler words
4. Structure the query to emphasize key terms
5. Include technical or domain-specific terminology if applicable

Provide only the optimized search query without any explanations, greetings, or additional commentary.

Example input: "how to fix a bike tire that's gone flat"
Example output: "bicycle tire repair puncture fix patch inflate maintenance flat tire inner tube replacement"

Constraints:
- Output only the enhanced search terms
- Keep focus on searchable concepts
- Include both specific and general related terms
- Maintain all important meaning from original query