modify this unity c# script so it has the same api key as the html i made. <html><head><base href="https://websim.ai/ai-llm-chat"><title>AI LLM Chat - WebSim</title><style>
  body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 20px;
    background-color: #f0f0f0;
  }
  .container {
    max-width: 800px;
    margin: 0 auto;
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 20px;
  }
  h1 {
    color: #333;
    text-align: center;
  }
  .model-select {
    width: 100%;
    padding: 10px;
    margin-bottom: 20px;
    border: 1px solid #ddd;
    border-radius: 4px;
  }
  .chat-container {
    height: 400px;
    overflow-y: auto;
    border: 1px solid #ddd;
    padding: 10px;
    margin-bottom: 20px;
    background-color: #f9f9f9;
  }
  .message {
    margin-bottom: 10px;
    padding: 8px;
    border-radius: 4px;
  }
  .user-message {
    background-color: #e1f5fe;
    text-align: right;
  }
  .ai-message {
    background-color: #f0f4c3;
  }
  .input-container {
    display: flex;
  }
  #user-input {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px 0 0 4px;
  }
  #send-button {
    padding: 10px 20px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
  }
  #send-button:hover {
    background-color: #45a049;
  }
</style></head><body>
  <div class="container">
    <h1>AI LLM Chat</h1>
    <select id="model-select" class="model-select">
      <option value="Qwen/Qwen2-72B-Instruct">Qwen2-72B-Instruct</option>
      <option value="mistralai/Mixtral-8x22B-Instruct-v0.1">Mixtral-8x22B-Instruct-v0.1</option>
      <option value="meta-llama/Meta-Llama-3-70B-Instruct">Meta-Llama-3-70B-Instruct</option>
      <option value="nvidia/Nemotron-4-340B-Instruct">Nemotron-4-340B-Instruct</option>
      <option value="microsoft/WizardLM-2-8x22B">WizardLM-2-8x22B</option>
      <option value="lizpreciatior/lzlv_70b_fp16_hf">lzlv_70b_fp16_hf</option>
    </select>
    <div id="chat-container" class="chat-container"></div>
    <div class="input-container">
      <input type="text" id="user-input" placeholder="Type your message here...">
      <button id="send-button">Send</button>
    </div>
  </div>

  <script>
    const chatContainer = document.getElementById('chat-container');
    const userInput = document.getElementById('user-input');
    const sendButton = document.getElementById('send-button');
    const modelSelect = document.getElementById('model-select');

    let conversationHistory = [];

    function addMessage(content, isUser) {
      const messageDiv = document.createElement('div');
      messageDiv.classList.add('message');
      messageDiv.classList.add(isUser ? 'user-message' : 'ai-message');
      messageDiv.textContent = content;
      chatContainer.appendChild(messageDiv);
      chatContainer.scrollTop = chatContainer.scrollHeight;
    }

    async function sendMessage() {
      const userMessage = userInput.value.trim();
      if (userMessage === '') return;

      addMessage(userMessage, true);
      userInput.value = '';

      conversationHistory.push({ role: 'user', content: userMessage });

      const selectedModel = modelSelect.value;

      try {
        const response = await fetch('https://api.deepinfra.com/v1/openai/chat/completions', {
          method: 'POST',
          headers: {
            'Content-Type': 'application/json',
          },
          body: JSON.stringify({
            model: selectedModel,
            messages: conversationHistory,
          }),
        });

        if (!response.ok) {
          throw new Error('API request failed');
        }

        const data = await response.json();
        const aiMessage = data.choices[0].message.content;

        addMessage(aiMessage, false);
        conversationHistory.push({ role: 'assistant', content: aiMessage });

      } catch (error) {
        console.error('Error:', error);
        addMessage('Sorry, there was an error processing your request.', false);
      }
    }

    sendButton.addEventListener('click', sendMessage);
    userInput.addEventListener('keypress', (e) => {
      if (e.key === 'Enter') {
        sendMessage();
      }
    });
  </script>
</body></html>. now the unity script. using UnityEngine;
using TMPro;
using UnityEngine.UI;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using UnityEngine.Networking;
using Newtonsoft.Json;
using System;

public class AdvancedAIScript : MonoBehaviour
{
    [Header("UI Elements")]
    public TMP_InputField userInputField;
    public TMP_Text aiResponseText;
    public Button submitButton;
    public ScrollRect scrollRect; // To auto-scroll to the latest response

    [Header("AI Settings")]
    public int MemoryLimit = 20; // Increased to store more exchanges
    public int TopicMemoryLimit = 5; // Memory for current topic

    private Queue<string> memory = new Queue<string>(); // General memory for context
    private Queue<string> topicMemory = new Queue<string>(); // Memory for topic tracking

    // DeepInfra API Settings
    [Header("DeepInfra API Settings")]
    [Tooltip("Your DeepInfra API Key")]
    public string deepInfraApiKey;
    [Tooltip("The model to use (e.g., gpt-4, gpt-3.5-turbo)")]
    public string deepInfraModel = "gpt-4";

    // API Endpoint
    private const string API_URL = "https://api.deepinfra.com/v1/openai/chat/completions";

    private void Start()
    {
        submitButton.onClick.AddListener(OnSubmit);
    }

    private void OnSubmit()
    {
        string userInput = userInputField.text.Trim();
        if (string.IsNullOrEmpty(userInput)) return;

        AddToMemory($"User: {userInput}");
        userInputField.text = string.Empty;

        // Process user input asynchronously
        ProcessUserInputAsync(userInput);
    }

    private void AddToMemory(string text)
    {
        if (memory.Count >= MemoryLimit)
            memory.Dequeue(); // Remove oldest memory

        memory.Enqueue(text);
    }

    private void AddToTopicMemory(string topic)
    {
        if (topicMemory.Count >= TopicMemoryLimit)
            topicMemory.Dequeue(); // Remove oldest topic

        topicMemory.Enqueue(topic);
    }

    private async void ProcessUserInputAsync(string input)
    {
        // Construct the conversation history
        string conversation = ConstructConversation();

        // Send the conversation to DeepInfra's API and get the response
        string aiResponse = await GetAIResponse(conversation);

        if (string.IsNullOrEmpty(aiResponse))
        {
            aiResponse = "I'm sorry, I couldn't process that.";
        }

        // Add AI response to memory
        AddToMemory($"AI: {aiResponse}");

        // Display the response
        aiResponseText.text += $"AI: {aiResponse}\n";
        ScrollToBottom();
    }

    private string ConstructConversation()
    {
        // Join the memory queue into a list of messages
        List<OpenAIMessage> messages = new List<OpenAIMessage>
        {
            new OpenAIMessage { role = "system", content = "You are a helpful assistant." }
        };

        foreach (var line in memory)
        {
            if (line.StartsWith("User: "))
            {
                messages.Add(new OpenAIMessage { role = "user", content = line.Substring(6) });
            }
            else if (line.StartsWith("AI: "))
            {
                messages.Add(new OpenAIMessage { role = "assistant", content = line.Substring(4) });
            }
        }

        // Serialize messages to JSON
        var payload = new OpenAIRequest
        {
            model = deepInfraModel,
            messages = messages
        };

        return JsonConvert.SerializeObject(payload);
    }

    private async Task<string> GetAIResponse(string jsonPayload)
    {
        using (UnityWebRequest request = new UnityWebRequest(API_URL, "POST"))
        {
            byte[] bodyRaw = System.Text.Encoding.UTF8.GetBytes(jsonPayload);
            request.uploadHandler = new UploadHandlerRaw(bodyRaw);
            request.downloadHandler = new DownloadHandlerBuffer();
            request.SetRequestHeader("Content-Type", "application/json");
            request.SetRequestHeader("Authorization", $"Bearer {deepInfraApiKey}");

            // Send the request and wait for a response
            var operation = request.SendWebRequest();

#if UNITY_2020_1_OR_NEWER
            while (!operation.isDone)
                await Task.Yield();
#else
            while (!operation.isDone)
                await Task.Delay(100);
#endif

            if (request.result == UnityWebRequest.Result.ConnectionError ||
                request.result == UnityWebRequest.Result.ProtocolError)
            {
                Debug.LogError($"Error: {request.error}");
                return null;
            }
            else
            {
                // Parse the response
                try
                {
                    var response = JsonConvert.DeserializeObject<DeepInfraResponse>(request.downloadHandler.text);
                    if (response != null && response.choices != null && response.choices.Count > 0)
                    {
                        return response.choices[0].message.content.Trim();
                    }
                    else
                    {
                        Debug.LogWarning("No response received from DeepInfra.");
                        return null;
                    }
                }
                catch (Exception ex)
                {
                    Debug.LogError($"Failed to parse AI response: {ex.Message}");
                    return null;
                }
            }
        }
    }

    private void ScrollToBottom()
    {
        Canvas.ForceUpdateCanvases();
        scrollRect.verticalNormalizedPosition = 0f;
    }
}

// OpenAI API Request Models
[Serializable]
public class OpenAIRequest
{
    public string model;
    public List<OpenAIMessage> messages;
}

[Serializable]
public class OpenAIMessage
{
    public string role; // "system", "user", "assistant"
    public string content;
}

// DeepInfra API Response Models
[Serializable]
public class DeepInfraResponse
{
    public string id;
    public string @object;
    public int created;
    public string model;
    public List<Choice> choices;
    public Usage usage;
}

[Serializable]
public class Choice
{
    public int index;
    public OpenAIMessage message;
    public string finish_reason;
}

[Serializable]
public class Usage
{
    public int prompt_tokens;
    public int completion_tokens;
    public int total_tokens;
}