You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_CodeGeeX_code_translation.py 1.0 kB

3 years ago
3 years ago
3 years ago
12345678910111213141516171819202122232425262728293031323334
  1. # Copyright (c) Alibaba, Inc. and its affiliates.
  2. import os
  3. import unittest
  4. from modelscope.pipelines import pipeline
  5. from modelscope.utils.constant import Tasks
  6. from modelscope.utils.demo_utils import DemoCompatibilityCheck
  7. from modelscope.utils.test_utils import test_level
  8. class CodeGeeXCodeTranslationTest(unittest.TestCase, DemoCompatibilityCheck):
  9. def setUp(self) -> None:
  10. self.output_dir = 'unittest_output'
  11. os.makedirs(self.output_dir, exist_ok=True)
  12. @unittest.skipUnless(test_level() >= 0, 'skip test in current test level')
  13. def test_run_with_CodeGeeX_with_name(self):
  14. model = 'ZhipuAI/CodeGeeX-Code-Translation-13B'
  15. pipe = pipeline(
  16. task=Tasks.code_translation,
  17. model=model
  18. )
  19. inputs = {
  20. 'prompt': 'for i in range(10):\n\tprint(i)\n',
  21. 'source language': 'Python',
  22. 'target language': 'C++'
  23. }
  24. result = pipe(inputs)
  25. print(result)
  26. if __name__ == '__main__':
  27. unittest.main()