I want an LLM to extract knowledge insights from an existing conversation between a user and its chat session with its psychologist/buddy. The idea is to summarize the most important ideas from the conversation so that later we can use them to provide more personalized and contextually relevant responses in future interactions. This is where the doc-LLM comes in.

The doc-LLM, or document-focused Language Model, is a specialized AI system designed to analyze conversations and extract key information. Here's how it works:

1. Input: The doc-LLM receives the entire conversation history between the user and the AI psychologist/buddy.

2. Analysis: It carefully reads through the conversation, identifying important themes, emotions, personal details, and potential issues or goals mentioned by the user.

3. Categorization: The doc-LLM organizes this information into predefined categories such as "Personal Relationships," "Emotional Patterns," "Goals and Aspirations," etc.

4. Document Creation: For each piece of significant information, the doc-LLM creates or updates a "document" in our knowledge base. These documents are structured with keys (like a title or topic) and values (the actual information).

5. Contextual Linking: The doc-LLM also identifies related persons for each piece of information, helping to build a network of relationships and contexts.

6. Relevance Scoring: Although we've decided to drop explicit relevance scoring, the doc-LLM still prioritizes information based on its importance to understanding the user.

7. Output: The result is a set of well-organized, concise documents that summarize the key insights from the conversation.

These documents can then be used by our main system to provide more informed, empathetic, and contextually appropriate responses in future interactions. The doc-LLM helps bridge the gap between raw conversation data and actionable insights, allowing our AI psychologist/buddy to build a deeper understanding of the user over time.

By periodically analyzing conversations with the doc-LLM, we can continuously update and refine our knowledge about the user, leading to more personalized and effective therapeutic interactions.

---

However, in a more lower level, in the implementation, i was using structured outputs from the LLM which doesn't work, because i need a flexible number of context cues, and the current schema always outputs one per conversation. For that reason, I want to migrate to a function-calling based approach. I need you to suggest a function name, description, and parameters to make it as easy as possible for the doc-llm to understand the task and take notes. The doc-llm won't type the 'key' itself so you can ignore that attribute. here is the previous code for reference about the parameters and stuff.

```
def extract_context(gemini: Gemini, messages):
    """
    Extract context from a conversation.
    """
    
    response_schema = content.Schema(
        type = content.Type.OBJECT,
        required = ["category", "subcategory", "content"],
        properties = {
            "category": content.Schema(
                type = content.Type.STRING
            ),
            "subcategory": content.Schema(
                type = content.Type.STRING
            ),
            "content": content.Schema(
                type = content.Type.STRING
            ),
            "related_persons": content.Schema(
                type = content.Type.ARRAY,
                items = content.Schema(
                    type = content.Type.STRING
                )
            )
        }
    )
    
    generation_config = {
        "temperature": 0.4,
        "top_p": 0.95,
        "top_k": 64,
        "max_output_tokens": 8192,
        "response_schema": response_schema,
        "response_mime_type": "application/json",
    }
    
    system_instruction = """
Analyze the following conversation and create or update information based on the conversation provided.
For each piece of significant information:
1. Determine the most appropriate category from the list: [Personal Relationships, Professional Life, Health and Wellness, Hobbies and Interests, Goals and Aspirations, Emotional Patterns, Significant Life Events]
2. Assign or create an appropriate subcategory. Existing subcategories: []
3. Provide a concise content string that summarizes the information
4. Identify any persons related to this information. Always specify some qualifier (e.g. "Janice (mother)", "Bob (long-time friend)"). If none, leave blank
"""

    response = gemini.chat(system_instruction=system_instruction,
                                    gen_config=generation_config,
                                    content=messages)
    
    try:
        context_updates = json.loads(response.text)
    except Exception as e:
        # TODO manage error
        raise Exception(f"Failed to extract context updates from Gemini response: {e}")
    
    return context_updates
   ```