Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: add llm debug page #3

Merged
merged 9 commits into from
May 18, 2024
Merged

Feat: add llm debug page #3

merged 9 commits into from
May 18, 2024

Conversation

Colin-XKL
Copy link
Owner

No description provided.

Colin-XKL added 9 commits May 14, 2024 15:20
"Added functionality to fetch and display article content and is_advertorial field from the backend /craft-debug/advertorial API in the LLM Debug Page."

# Aider chat conversation:

USER: in llm-debug page, when user input a article url and click submit button , then make request to backend /craft-debug/advertorial api and get response, then extract the article content field and is_advertorial field, then show them in the page

ASSISTANT:  To implement the feature you described, we need to modify the `llm-debug.vue` file. Here are the changes:

web/admin/src/views/dashboard/llm-debug/llm-debug.vue
```vue
<<<<<<< SEARCH
<template>
  <div class="py-8 px-16">
    <h1 class="text-3xl font-bold">LLM Debug Page</h1>
    <!-- Add your content here -->
  </div>
</template>

<script lang="ts" setup>
  // Add your script here
</script>

<script lang="ts">
  export default {
    name: 'LLMDebug',
  };
</script>
=======
<template>
  <div class="py-8 px-16">
    <h1 class="text-3xl font-bold">LLM Debug Page</h1>
    <a-card class="my-2" title="输入链接">
      <p>输入要预览的RSS源地址 支持RSS/ATOM</p>
      <a-space>
        <a-input
          v-model="articleUrl"
          type="text"
          placeholder="Enter article URL"
        />
        <a-button @click="fetchArticle">Submit</a-button>
      </a-space>
    </a-card>
    <a-card title="结果预览" class="my-4">
      <div v-if="articleContent">
        <p>Article Content: {{ articleContent }}</p>
        <p>Is Advertorial: {{ isAdvertorial }}</p>
      </div>
      <a-empty v-else />
    </a-card>
  </div>
</template>

<script lang="ts" setup>
import { ref } from 'vue';
import { Message } from '@arco-design/web-vue';

const articleUrl = ref('');
const articleContent = ref('');
const isAdvertorial = ref(false);

async function fetchArticle() {
  const requestUrl = `${baseUrl}/craft-debug/advertorial`;
  try {
    const resp = await fetch(requestUrl, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({ url: articleUrl.value }),
    });
    const data = await resp.json();
    articleContent.value = data.article_content;
    isAdvertorial.value = data.is_advertorial;
  } catch (error) {
    Message.warning(error?.toString() ?? 'Unknown Error');
    console.error(error);
  }
}
</script>

<script lang="ts">
  export default {
    name: 'LLMDebug',
  };
</script>
>>>>>>> REPLACE
```
… for simplified HTTP POST requests."

# Aider chat conversation:

USER: use axios to make it more simple

ASSISTANT:  Sure, I can help you simplify the fetchArticle function in the `llm-debug.vue` file using axios. Here's the *SEARCH/REPLACE* block for the changes:

web/admin/src/views/dashboard/llm-debug/llm-debug.vue
```vue
<<<<<<< SEARCH
async function fetchArticle() {
  const requestUrl = `${baseUrl}/craft-debug/advertorial`;
  try {
    const resp = await fetch(requestUrl, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({ url: articleUrl.value }),
    });
    const data = await resp.json();
    articleContent.value = data.article_content;
    isAdvertorial.value = data.is_advertorial;
  } catch (error) {
    Message.warning(error?.toString() ?? 'Unknown Error');
    console.error(error);
  }
}
=======
import axios from 'axios';

async function fetchArticle() {
  try {
    const resp = await axios.post(`${baseUrl}/craft-debug/advertorial`, {
      url: articleUrl.value,
    });
    articleContent.value = resp.data.article_content;
    isAdvertorial.value = resp.data.is_advertorial;
  } catch (error) {
    Message.warning(error?.toString() ?? 'Unknown Error');
    console.error(error);
  }
}
>>>>>>> REPLACE
```

This change simplifies the fetchArticle function by using axios to make the POST request. It also imports axios at the top of the script.
# Conflicts:
#	web/admin/src/views/dashboard/llm-debug/llm-debug.vue
@Colin-XKL Colin-XKL merged commit c991216 into main May 18, 2024
4 checks passed
@Colin-XKL Colin-XKL deleted the feat/add-llm-debug-page branch May 18, 2024 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant