-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: System application generate prompt #4034
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -75,13 +75,23 @@ | |
|
|
||
| <script setup lang="ts"> | ||
| import { computed, reactive, ref } from 'vue' | ||
| import { useRoute } from 'vue-router' | ||
| import systemGeneratePromptAPI from '@/api/system-resource-management/application' | ||
| import generatePromptAPI from '@/api/application/application' | ||
| import useStore from '@/stores' | ||
| const emit = defineEmits(['replace']) | ||
| const { user } = useStore() | ||
| const route = useRoute() | ||
|
|
||
| const chatMessages = ref<Array<any>>([]) | ||
|
|
||
| const apiType = computed(() => { | ||
| if (route.path.includes('resource-management')) { | ||
| return 'systemManage' | ||
| } else { | ||
| return 'workspace' | ||
| } | ||
| }) | ||
| // 原始输入 | ||
| const originalUserInput = ref<string>('') | ||
| const modelID = ref('') | ||
|
|
@@ -204,10 +214,21 @@ function generatePrompt(inputValue: any) { | |
| messages: chatMessages.value, | ||
| prompt: promptTemplates.INIT_TEMPLATE, | ||
| } | ||
| generatePromptAPI.generate_prompt(workspaceId, modelID.value, applicationID.value,requestData).then((response) => { | ||
| if (apiType.value === 'workspace') { | ||
| generatePromptAPI.generate_prompt(workspaceId, modelID.value, applicationID.value,requestData) | ||
| .then((response) => { | ||
| const reader = response.body.getReader() | ||
| reader.read().then(getWrite(reader)) | ||
| }) | ||
| } else if (apiType.value === 'systemManage') { | ||
| console.log(apiType.value) | ||
| systemGeneratePromptAPI.generate_prompt(applicationID.value, modelID.value, requestData) | ||
| .then((response) => { | ||
| const reader = response.body.getReader() | ||
| reader.read().then(getWrite(reader)) | ||
| }) | ||
| } | ||
|
|
||
| } | ||
|
|
||
| // 重新生成点击 | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here's a revised version of the provided Vue.js SFC with some fixes, improvements, and optimizations: <script setup lang="ts">
import { computed, reactive, ref, onMounted } from 'vue';
import { useRoute } from 'vue-router';
import systemGeneratePromptAPI from '@/api/system-resource-management/application';
import generatePromptAPI from '@/api/application/application';
import useStore from '@/stores';
const emit = defineEmits(['replace']);
const { user } = useStore();
const route = useRoute();
// Reactive arrays or objects
const chatMessages = ref([]);
const originalUserInput = ref('');
const modelID = ref('');
// Computed properties
const apiType = computed(() => {
if (route.path.includes('resource-management')) {
return 'systemManage';
} else {
return 'workspace';
}
});
// Methods
function generatePrompt(inputValue: any) {
const requestData = {
workspaceId: /* your workspace ID */, // Replace this with actual logic to determine workspcae ID
promptTemplate: inputValue !== '' ? promptTemplates.INIT_TEMPLATE : '',
// Add other request data here
};
// Determine which API to call based on the current route path
if (apiType.value === 'workspace') {
generatePromptAPI.generate_prompt(requestData).then((response) => {
const reader = response.body.getReader();
reader.read().then(getWrite(reader));
});
} else if (apiType.value === 'systemManage') {
systemGeneratePromptAPI.generate_prompt(requestData).then((response) => {
const reader = response.body.getReader();
reader.read().then(getWrite(reader));
});
}
}
function getWrite(reader) {
// Handle read events for each chunk
}
onMounted(() => {
// Initialize state and perform other initialization tasks
});
</script>Key Improvements and Fixes:
Make sure to replace placeholders like |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The provided code looks clean and well-structured. However, here are a few minor suggestions for improvement:
Type Declarations: Adding type declarations to the parameters can improve maintainability and clarity.
Whitespace Consistency: Ensure consistent use of whitespace within function bodies and around operators for readability.
Here's an updated version of the code with these improvements:
Key Changes:
Ref<boolean>,PostResponse<string>).PostResponseis imported from'@/types'.These changes enhance the overall quality and organization of the code while maintaining its functionality.