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

When publishing workflow as tool, it does not show up in Tools #4697

Closed
4 tasks done
AndyMik90 opened this issue May 27, 2024 · 4 comments
Closed
4 tasks done

When publishing workflow as tool, it does not show up in Tools #4697

AndyMik90 opened this issue May 27, 2024 · 4 comments
Labels
🔨 feat:tools Tools for agent, function call related stuff.

Comments

@AndyMik90
Copy link

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.6.9

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

There seems to be an issue when publishing workflows as tools that they don't show up in the ProviderList:
CleanShot 2024-05-27 at 20 31 40
But I can see them in the studio:
CleanShot 2024-05-27 at 20 32 03

✔️ Expected Behavior

Show workflow as tools, just as on cloud.

❌ Actual Behavior

Empty view. When adding debug to web/app/components/tools/provider-list.tsx there seem to be a mismatch between the
useEffect for the active tab, and the Collection type
"Collection type: builtin Active tab: workflow"

@dosubot dosubot bot added the 🔨 feat:tools Tools for agent, function call related stuff. label May 27, 2024
Copy link

dosubot bot commented May 27, 2024

The issue you're experiencing, where the workflow does not show up in the Tools section when published, despite appearing correctly in the studio interface, could be due to the filtering logic in the ProviderList component. Specifically, the workflow will only appear if it matches the active tab, tag filters, and keyword search criteria.

Here is the relevant code snippet that filters the collection list:

const filteredCollectionList = useMemo(() => {
  return collectionList.filter((collection) => {
    if (collection.type !== activeTab)
      return false
    if (tagFilterValue.length > 0 && (!collection.labels || collection.labels.every(label => !tagFilterValue.includes(label))))
      return false
    if (keywords)
      return collection.name.toLowerCase().includes(keywords.toLowerCase())
    return true
  })
}, [activeTab, tagFilterValue, keywords, collectionList])

Ensure that:

  1. The activeTab is set to 'workflow'.
  2. The workflow has the appropriate tags that match tagFilterValue.
  3. The workflow's name matches the keywords if any are set.

Additionally, ensure that the workflow is not marked as outdated. The outdated state is determined by comparing the workflow's parameters with the expected inputs. If there is a mismatch, the workflow might not be considered up-to-date and thus not shown. Here is the relevant code snippet:

const outdated = useMemo(() => {
  if (!detail)
    return false
  if (detail.tool.parameters.length !== inputs?.length) {
    return true
  }
  else {
    for (const item of inputs || []) {
      const param = detail.tool.parameters.find(toolParam => toolParam.name === item.variable)
      if (!param) {
        return true
      }
      else if (param.required !== item.required) {
        return true
      }
      else {
        if (item.type === 'paragraph' && param.type !== 'string')
          return true
        if (param.type !== item.type && !(param.type === 'string' && item.type === 'paragraph'))
          return true
      }
    }
  }
  return false
}, [detail, inputs])

If any of these conditions are not met, the workflow will not appear in the Tools section.

Additionally, in a self-hosted environment, ensure that the necessary services are correctly configured and running. For example, the api, web, and nginx services should be properly set up in your docker-compose.yaml file. Here is a snippet of the relevant configuration:

version: '3'
services:
  api:
    image: langgenius/dify-api:0.6.9
    restart: always
    environment:
      MODE: api
      LOG_LEVEL: INFO
      SECRET_KEY: sk-9f73s3ljTXVcMT3Blb3ljTqtsKiGHXVcMT3BlbkFJLK7U
      MIGRATION_ENABLED: 'true'
      DB_USERNAME: postgres
      DB_PASSWORD: difyai123456
      DB_HOST: db
      DB_PORT: 5432
      DB_DATABASE: dify
      REDIS_HOST: redis
      REDIS_PORT: 6379
      REDIS_PASSWORD: difyai123456
      CELERY_BROKER_URL: redis://:difyai123456@redis:6379/1
    depends_on:
      - db
      - redis
    volumes:
      - ./volumes/app/storage:/app/api/storage
    networks:
      - ssrf_proxy_network
      - default

  web:
    image: langgenius/dify-web:0.6.9
    restart: always
    environment:
      CONSOLE_API_URL: ''
      APP_API_URL: ''
    networks:
      - default

  nginx:
    image: nginx:latest
    restart: always
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf
      - ./nginx/proxy.conf:/etc/nginx/proxy.conf
      - ./nginx/conf.d:/etc/nginx/conf.d
    depends_on:
      - api
      - web
    ports:
      - "80:80"
networks:
  ssrf_proxy_network:
    driver: bridge
    internal: true
  default:
    driver: bridge

Ensure that all services are up and running, and that there are no network issues preventing the frontend from communicating with the backend.

Additionally, ensure that the workflow provider details are correctly fetched and displayed. The ProviderDetail component handles the fetching and displaying of workflow tool details. Make sure that the getWorkflowToolProvider function is correctly fetching the workflow tool details and updating the state accordingly:

const getWorkflowToolProvider = useCallback(async () => {
  setIsDetailLoading(true)
  const res = await fetchWorkflowToolDetail(collection.id)
  const payload = {
    ...res,
    parameters: res.tool?.parameters.map((item) => {
      return {
        name: item.name,
        description: item.llm_description,
        form: item.form,
        required: item.required,
        type: item.type,
      }
    }) || [],
    labels: res.tool?.labels || [],
  }
  setCustomCollection(payload)
  setIsDetailLoading(false)
}, [collection.id])

Ensure that the ProviderDetail component is correctly rendering the workflow tool details and that the isDetailLoading state is managed properly [1][2][3][4].

Details

About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

@patryk20120
Copy link
Contributor

Well, works for me. Try refresh and see the console logs (if any errors) - if not would be nice to see container logs (api).

@AndyMik90
Copy link
Author

I don't know if it's related, but when I'm adding anything other then a builtin tool, the icon changes upon adding it:
CleanShot 2024-05-27 at 23 55 26
Then when I try access the "info and setting" for the tool, it just is in isLoading forever
CleanShot 2024-05-27 at 23 58 01
It's no problem with builtin tools:
CleanShot 2024-05-27 at 23 57 09

I can see that the icon is correct in the DB.

@AndyMik90
Copy link
Author

Found the error ,was something on my side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 feat:tools Tools for agent, function call related stuff.
Projects
None yet
Development

No branches or pull requests

2 participants