# Chat with PowerPoint Presentation

### Import the required libraries

```python
from beyondllm import source,retrieve,embeddings,llms,generator
```

### Setup API key

```python
import os
from getpass import getpass
os.environ['GOOGLE_API_KEY'] = getpass('Put the Google API Key here')
```

### Load the Source Data

Here we will use a sample powerpoint on Document Generation Using ChatGPT. You have to provide the path to your ppt file here

```python
data = source.fit("path/to/your/powerpoint/file",dtype="ppt",chunk_size=512,chunk_overlap=51)
```

### Embedding model

We have the default Embedding Model which is GeminiEmbeddings in this case. You will have to specify your API key as an environment variable named: `GOOGLE_API_KEY`&#x20;

### Auto retriever to retrieve documents

```python
retriever = retrieve.auto_retriever(data,type="normal",top_k=3)
```

### Run Generator Model

```python
pipeline = generator.Generate(question="what is this powerpoint presentation about?",retriever=retriever)
print(pipeline.call())
```

#### Output

```
The presentation focuses on exploring the depths of document generation using GPT-3.5. It entails a detailed walkthrough of the methodologies employed, shedding light on the current state, and presenting avenues for future advancements.
```

#### Deploy Inference - Gradio

```python
import gradio as gr

def predict(message, history, system_prompt, tokens):
  response =  pipeline.call()
  return response

with gr.Blocks() as demo:
    chatbot = gr.Chatbot()
    msg = gr.Textbox()
    clear = gr.ClearButton([msg, chatbot])

    def predict(message, chat_history):
      response = pipeline.call()
      chat_history.append((message, response))
      return "", chat_history


    msg.submit(predict, [msg, chatbot], [msg, chatbot])

demo.launch(share = True)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://beyondllm.aiplanet.com/use-cases/chat-with-powerpoint-presentation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
